Run mysql_query on a jquery request
Posted: Mon Nov 24, 2008 6:42 pm
I will try and explain this as best i can. I will post code below but just tell me to post any other info you need.
I have a CMS that i am building, and when a user goes to the "pages" section they can add edit or delete pages. So somebody clicks on the delete button and it shows a modal box (http://onehackoranother.com/projects/jquery/boxy/) and you can confirm yes or no that you want to delete that page. If you click no, the modal box goes away, and if you click yes, the modal box goes away and the page fades out from the listing.
So all that's missing is actually deleting the page from the database. But i cant figure out a way to run the mysql query to delete the page once the user has clicked the "yes" button. I would like to have no page refreshes in this process as well.
Suggestions?
Thanks,
-Shan
CODE:
//delete.php that gets called into the modal box
I have a CMS that i am building, and when a user goes to the "pages" section they can add edit or delete pages. So somebody clicks on the delete button and it shows a modal box (http://onehackoranother.com/projects/jquery/boxy/) and you can confirm yes or no that you want to delete that page. If you click no, the modal box goes away, and if you click yes, the modal box goes away and the page fades out from the listing.
So all that's missing is actually deleting the page from the database. But i cant figure out a way to run the mysql query to delete the page once the user has clicked the "yes" button. I would like to have no page refreshes in this process as well.
Suggestions?
Thanks,
-Shan
CODE:
//delete.php that gets called into the modal box
Code: Select all
<?php
$id = $_GET['id'];
require '../../lib/inc/config.php';
print'<div>';
print'<a href="" onclick="deleteRow();" class="close yes">Yes, Delete it.</a>';
print'<a href="" class="close noo">Oops, Didn\'t mean to click that</a>';
print'</div>';
?>
<?php #mysql_query("DELETE FROM pages WHERE entryID = '$id'"); ?>
<script type="text/javascript">
function deleteRow(){
$("#row-<?php print $id; ?>").slideUp(500);
}
</script>