Jump to content

help with sql delete


noclist

Recommended Posts

I am building a user interface to manipulate a database I have in mySQL and one of the functions is deleting records from a table I call Titles. Given my primary key is mID and a column in the table is Title, here is the code I'm working with:

 

$sql="delete from myDb.Titles where mID=" . $_GET['mID'];

if (mysql_query($sql))
{
    $target="delete.php?";
}

echo "Successfully deleted title: " . $_GET['Title'];

 

The actual delete itself is working fine and the record deletes properly. What I am trying to do is display the Title field associated with the record being deleted and it's not working. I don't know if I am misusing the GET function or not, but that's where I am. Any help would be appreciated.

 

Link to comment
Share on other sites

Unless you have a variable appended to the URL called 'Title' that actually holds the value of the title (such as script.php?id=123456&Title=sometitle) then yes, you are using it incorrectly. You'd need to run a SELECT query first (possibly in the same script that gets the PK id) to retrieve the value of the Title field from the record, then echo it after the DELETE query.

Link to comment
Share on other sites

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.