What I am trying to do, is say I have 1 piece of data with id 1, one with id 2, and one with 3. Using this code, I can successfully delete the selected data by id, but also what I want to do is for every id above the one deleted, I want to make them go down by 1, like the one with id of 2 would go to 1, and the one with id of 3 would go to 2, the code below is what I have tried, and been unsuccessful
This is my code so far:
$sqldelete = "DELETE from `banners` WHERE id='".$deleteid."'";
$resdelete = mysql_query($sqldelete) or die(mysql_error());
$upsql = "SELECT * FROM `banners` WHERE id > '".$deleteid."'";
$upres = mysql_query($upsql) or die(mysql_error());
$array[] = $upres;
foreach($array AS $idnum)
{
$idstart = $deleteid + $idnum;
$idupdate = $idstart - 1;
$sqlupdate = "UPDATE `banners` SET id='".$idupdate."' WHERE id='".$idstart."'";
$sqlres = mysql_query($sqlupdate);
}
echo "You have successfully deleted the item with an ID of ".$deleteid."!";