Re: php mysql problem
| From: | John | Date: | Tue, 02 May 2006 17:27:30 +0000 |
| Subject: | Re: php mysql problem | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-235287@lists.php.net to get a copy of this message | ||
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. CREATE TABLEHi Ross, You can reuse item_id after they have been deleted. So when you delete item_id = 1, then next time you perform an insert, lookup the lowest free item_id number and give it as the item_id. That's one small solution. If you actually want to rank your records by more than just the item_id, then define a field for each kind of rank you want, or better, add it as a separate table, like: board_papers -----< rankboard_papers(idint(4) NOT NULL auto_increment,doc_datevarchar(10) NOT NULL default '0000-00-00',article_typeenum('agenda','minutes','paper') NOT NULL default 'agenda',fileNamevarchar(50) NOT NULL default '',fileSizeint(4) NOT NULL default '0',fileTypevarchar(50) NOT NULL default '',contentblob NOT NULL,item_idint(10) default NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; -- snip --
* id
* board_papers_fk <-- id from board_papers
* rank_type (example: readability, technicality...)
* rank_no (rank within the rank type)
Then you can order the board_papers after rank as you like!
Just an idea :)
Enjoy,
John