Maq Posted February 19, 2009 Share Posted February 19, 2009 I don't have an environment to test this in right now but it should work... session_start(); if (isset($_GET['idpub'])) { //Record passed on the query string for deletion //NOTE: You will need to correct this code for the right field names include('connections.php'); $idpub = mysql_real_escape_string($_GET['idpub']); //Get the name and abbreviation for the form $sql = "SELECT name, abbreviation FROM publisher WHERE idpub=$idpub"; $result = mysql_query($sql) or die(mysql_error()); $record = mysql_fetch_assoc($result); $name = $record['name']; $abbreviation = $record['abbreviation']; } else { //No id passed on GET or POST - error handling echo "No record selected"; //exit(); } //User confirmed the deletion if (isset($_POST['submitYes'])) { include('connections.php'); $idpub = mysql_real_escape_string($_POST['idpub']); $sql = "DELETE FROM publisher WHERE idpub='$idpub'"; $result = mysql_query($sql) or die(mysql_error()); mysql_free_result($result); echo "The record has been deleted."; } //User selected NOT to delete. Redirect somewhere else if (isset($_POST['submitNo'])) { echo "The record has NOT been deleted."; } ?> </pre> <table border="1" cellpadding="0" cellspacing="0" width="500"> You have selected '' for deletion. Do you want to continue with the delete action?   </table> <br><b Quote Link to comment https://forums.phpfreaks.com/topic/145237-strugling-to-finnish-this-site/page/2/#findComment-766175 Share on other sites More sharing options...
franklos Posted February 19, 2009 Author Share Posted February 19, 2009 Hi It does work but.... I had to comment out //mysql_free_result($result); supplied argument is not a valid MySQL result resource ? huh? And the page that should mention that "the record has been deleted" also states it has "the record has not been deleted" and it turns back to an empty page with the submit form? Strano. Thanks loads so far, Frank. Quote Link to comment https://forums.phpfreaks.com/topic/145237-strugling-to-finnish-this-site/page/2/#findComment-766281 Share on other sites More sharing options...
franklos Posted February 20, 2009 Author Share Posted February 20, 2009 hi, don't know if this is related, but if I delete, it deletion does not seem to update the row numbers. Before a delete I can add a publisher. Once I deleted a publisher I get a "Could not run query: Duplicate entry '122' for key 1 " error. Have a nice weekend, Frank. Quote Link to comment https://forums.phpfreaks.com/topic/145237-strugling-to-finnish-this-site/page/2/#findComment-766855 Share on other sites More sharing options...
franklos Posted February 28, 2009 Author Share Posted February 28, 2009 @Maq, thanks for your script, finally it does delete. Still some errors but hey one step at a time. Thanks all. PS attached an image of the page I see when I hit submit and deletion is done. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/145237-strugling-to-finnish-this-site/page/2/#findComment-773485 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.