Re: Taking X records, removing one record in the middle, then renumber...
| From: | Pavel Jartsev | Date: | Mon, 06 Nov 2000 15:18:51 +0000 |
| Subject: | Re: Taking X records, removing one record in the middle, then renumber... | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-23894@lists.php.net to get a copy of this message | ||
Sorry,
previous function wasn't right. This is better:
<?
function delete_o_matic( $victim_id )
{
/* delete victim ... */
mysql_query( "DELETE FROM table_name WHERE cid=".$victim_id );
/* ... and update other lucky items */
mysql_query( "UPDATE table_name SET cid=cid-1 WHERE cid >
".$victim_id);
}
?>
--
Pavel a.k.a. Papi