jquery-tabledit
jquery-tabledit copied to clipboard
Insert query result into column of editable array
This is my tabledit:
$('#usertable').Tabledit({ url: 'accountinfo.php', editButton: true, deleteButton: true, hideIdentifier: true, columns: { identifier: [0, 'id'], editable: [[1, 'name'], [2, 'email'], [3, 'admin', '{"1": "Yes", "0": "No"}'], [4, 'class']] }, onSuccess: function(data, textStatus, jqXHR) { viewData(); }, });
In the 4th column 'class' I would like to insert all the classes that I have in my database, like 1: Art, 2: Science, 3: History... and so on. But I want to get those classes from my database. I have a table called "class". How to insert them into the column and how to make the selection correctly? (to update in the database). Each class has its own id.
insert into class (name, email, admin, class) value ('" . $input['name'] . "', '" . $input['email'] . "', '" . $input['admin'] . "', '" . $input['class'] . "')
$('#usertable').Tabledit({ url: 'accountinfo.php', editButton: true, deleteButton: true, hideIdentifier: true, columns: { identifier: [0, 'id'], editable: [[1, 'name'], [2, 'email'], [3, 'admin', '{"1": "Yes", "0": "No"}'], [4, 'class','{"1": "Art", "2": "Science", "3": "History"}']] }, onSuccess: function(data, textStatus, jqXHR) { viewData(); }, });
declare a variable with JSON format and pass it to your variable 4 as ..
..[4, 'class', $json]