How do i do a loop to delete multiple rows in my database?
Hi,
I am trying to delete multiple rows in my database by their id. Firstly I have done a search on the database ($rsDr) to select these ids based on certain criteria, and now i want to run the delete code for every row found in the search.
I have tried and tried do ... while loops with the code but am getting no where, each time only one record is deleted not every record. Any help or advise would be much appreciated.
The code I am using for the delete is :
if (isset($row_rsDr['rentalsid']) && ($row_rsDr['rentalsid'] != "")) {
$deleteSQL = sprintf("DELETE FROM rentalstable WHERE rentalsid=%s",
GetSQLValueString($row_rsDr['rentalsid'], "int"));
mysql_select_db($database_connDelete, $connDelete);
$Result1 = mysql_query($deleteSQL, $connDelete) or die(mysql_error());
}
and i have been trying to use
$row_rsDr = mysql_fetch_assoc($rsDr);
from the search in a do ... while loop so that a delete is done for every id found in the recordset.
I look forward to any suggestions.
