Nope. Everything seems to be in order.
placeholder for popup β
<div id="popup"></div>
jQuery ui dialog β
$('#popup').dialog({
autoOpen: 'false',
modal: 'true',
minHeight: '300px',
minWidth: '300px',
buttons: {
'Save Changes': function(){
$.ajax({
url: 'path/to/my/page.ext',
type: 'POST',
data: $(this).find('form').serialize(),
success: function(data){
$(this).dialog('close');
}
});
},
'Discard & Exit' : function(){
$(this).dialog('close');
}
}
});
Now that the default settings have been created, send an ajax request for the data from the php file and update the contents in the pop pop div.
$('.edit').click(function(e){
e.preventDefault();
$.ajax({
url: 'path/to/my/page.ext',
type: 'GET',
data:
success: function(data){
$('#popup').html(data);
$('#popup').dialog('open');
}
});
});
on the PHP page, create a form to submit back β
<?php
if(isset($_GET['id'])){
$query = mysql_query(sprintf("SELECT * FROM sometable WHERE id = %d", $_GET['id']));
?>
<form>
<?php
while($row = mysql_fetch_array($query)){
?>
<tr>
<td>
<input type="text" name="<?php echo $row['id']?>" value="<?php echo $row['name'] ?>" />
</td>
</tr>
<?php
}
?>
</form>
<?php
}
?>
source
share