Jump to content

Recommended Posts

Hey,

  I'm writting a script that deletes multiple rows from a mysql db.

this is how I'm doing it at the moment

$db_headers=mysql_query("SELECT * FROM `headers` WHERE `header` = '".$_POST['head_index']."'");
while(list($index, $name, $internal, $inlink, $exlink, $header, $sort, $act)=mysql_fetch_array($db_headers))
{
	$query="DELETE FROM `headers` WHERE `headers` = ".index." LIMIT 1";
                          mysql_query($query);
                          $resaults .=$name." hass been deleted.";
}

 

i know i could do this

 

mysql_query("DELETE FROM `headers` WHERE `header` = '".$_POST['head_index']."'");

 

how ever how would i get the Fields it deleted?

Link to comment
https://forums.phpfreaks.com/topic/156942-viewing-names-of-deleted-mysql-rows/
Share on other sites

well in the top example that's what i did,

how ever i was wondering if there was a function that would mark down a value be deleting it. that way i don't have to scan the db twice, if not i can continue doing it the way i originally had it.

In most real life applications data is not actually deleted. It if was worth the time to insert it into a table it is valuable enough to keep for some future purpose (restore, reporting, tracking...) It is just marked as being deleted or it is moved to a deleted item table.

i thought i would reword my last statment:

 

well in the top example I do select all the values before deleting them, so i can have a list of what was deleted.

however I was wondering if there was a function that would select and mark down a value before deleting it.

That way i dont have to do 2 db querys.

 

And i do need to delete them, there is no reason i would need to resotre them.

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.