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
https://forums.phpfreaks.com/topic/218897-help-with-sql-delete/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.