I need a help in making a page where you can see data from a mysql query. Every row is echoed as a div
with a unique id
.
<div class="column" id="<?php echo $row['id']; ?>">
It has the same id as the data in the mysql database. Every div
contains an edit button:
<a href="edit_column.php?id=<?php echo $row['id'] ?>" class="edit">Edit</a>
After clicking 'edit', a jQuery script is executed:
$('.edit').on('click', function() {
var url = this.href;
var dialog = $("#dialog");
if ($("#dialog").length == 0) {
dialog = $('<div id="dialog" style="display:hidden"></div>').appendTo('body');
}
dialog.load(
url,
{},
function(responseText, textStatus, XMLHttpRequest) {
dialog.dialog();
}
);
return false;
})
Then, a dialog box pops up with a HTML form and I even managed to put MySQL data into that form to edit it. But now I don't know how to continue. How should I continue to update the data in the database? I know how to update it with PHP and I even have a PHP script update_column.php
but I don't know how to execute it from the dialog box and refresh the respective div
element with updated data without refreshing the whole page in the browser. In edit_column.php
, I only have the HTML form and the PHP script which returns data from the MySQL database.