Re: Re: php mysql problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 2, 2006 7:05 am, Ross wrote:
> This is my database now...I will use the item_id for the order but
> what if I
> want to change item_id 3 to item id 1? How can I push all the items
> down one
> place? How can I delete any gaps when items are deleted.

Change item_id 3 to 1.

... select id from board_papers where item_id = 3
... $id3 = mysql_result($result);
... select id from board_papers where item_id = 1
... $id1 = mysql_result($result);
... update board_papers set item_id = 1 where id = $id3
... update board_papers set item_id = 3 where id = $id1


Delete an item:

$item_id = 42;
... delete from board_papers where item_id = 42
... update board_papers set item_id = item_id - 1 where item_id > 42


It's up to you to actually add all the function calls and quotes and
error-checking and make it work for variables instead of constants.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux