Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Created March 10, 2011 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterdavis/864492 to your computer and use it in GitHub Desktop.
Save walterdavis/864492 to your computer and use it in GitHub Desktop.
<?php
define('MYACTIVERECORD_CONNECTION_STR', 'mysql://yourDatabaseUserName:yourDatabasePassword@localhost/yourDatabaseName');
class Widgets extends MyActiveRecord {
//nothing else needed here
}
$visible_columns = array();
$columns = MyActiveRecord::Columns('Widgets');
$out = '<table class="editable"><tr>'; //added the editable class
foreach($columns as $key => $column){
if($key != 'id'){
$out .= '<th id="' . $key . '">' . $key . '</th>'; //added column id
$visible_columns[] = $key;
}
}
$out .= '</tr>';
$widgets = MyActiveRecord::FindAll('Widgets');
foreach($widgets as $widget){
$out .= "\n<tr id=\"row_" . $widget->id . "\">"; //added row id
foreach($visible_columns as $col){
$out .= '<td>' . $widget->h($col) . '</td>';
}
$out .= '</tr>';
}
$out .= '</table>';
?>
<script type="text/javascript">
TableKit.options.editAjaxURI = 'update.php';
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment