Jump to content

strugling to finnish this site


franklos

Recommended Posts

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?
      
    
  
  &nbsp
  
    
      
      
      
      
      
    
  
</table>
<br><b

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.