Demonic Posted September 6, 2006 Share Posted September 6, 2006 Alright you know you order stuff by ids say you make a posting script and you order them by ID how could you rearange the ordering without messing with the post id's?say you have 4 cats order by id ASC 1234how would i order then like this3241?anybody have any suggestions its done on almost all forum systems. Quote Link to comment Share on other sites More sharing options...
ghettostickers Posted September 6, 2006 Share Posted September 6, 2006 thats confusing....try to explain it differently... Quote Link to comment Share on other sites More sharing options...
xyph Posted September 6, 2006 Share Posted September 6, 2006 Agreed. What would you like to order by? Quote Link to comment Share on other sites More sharing options...
Demonic Posted September 6, 2006 Author Share Posted September 6, 2006 thats the problem i dont know how to order them since you can only have 1 auto_increment per tablei want to order my categorys in a different waymy sql is like this mysql_query("SELECT * FROM table order by id DESC") simple enoughthey come in order like thiscat 1cat 2cat 3but i want to rearange them in some sort of fasion so they order by some number like say i had the rearanging script now all cat's would be ordered like this:cat 3cat 1cat 2see what i mean i need to find a way on how to order the categories threw a form and update them is it possible to give alter tables and make a default number until its updated threw the form and order them that way?say i alter the catgory table and make default 1 so all new cats will be 1 until thier updated then i want to order by that number. Very hard to explain since im not great with explaining nothen. ALTER TABLE `categories` ADD `order` INT( 10 ) NOT NULL DEFAULT '1' AFTER `id` and all are 1 right now :) <didnt work :( Quote Link to comment Share on other sites More sharing options...
trq Posted September 6, 2006 Share Posted September 6, 2006 You would need to create a specific field (order_by) with which you can specify whatever order you want your records to appear. eg[code]id order_by__________________1 32 63 14 55 26 4[/code]Given th above example, the following query...[code]SELECT id FROM tbl ORDER BY order_by[/code]would produce...[code]id___________________351642[/code]Does that help explain it? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.