Jump to content


Photo

might be a tuffy :(


  • Please log in to reply
4 replies to this topic

#1 Demonic

Demonic
  • Members
  • PipPipPip
  • Advanced Member
  • 562 posts

Posted 06 September 2006 - 02:12 AM

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
1
2
3
4

how would i order then like this

3
2
4
1
?

anybody have any suggestions its done on almost all forum systems.

#2 ghettostickers

ghettostickers
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 06 September 2006 - 02:31 AM

thats confusing....
try to explain it differently...

#3 xyph

xyph
  • Staff Alumni
  • Advanced Member
  • 3,712 posts
  • LocationSurrey, BC

Posted 06 September 2006 - 02:33 AM

Agreed. What would you like to order by?
Everything you need to know about storing user-names and passwords
http://www.openwall....Users-Passwords
Blank Page? Try forcing errors to display
ini_set('display_errors',1);
error_reporting(-1);

#4 Demonic

Demonic
  • Members
  • PipPipPip
  • Advanced Member
  • 562 posts

Posted 06 September 2006 - 02:40 AM

thats the problem i dont know how to order them since you can only have 1 auto_increment per table

i want to order my categorys in a different way

my sql is like this mysql_query("SELECT * FROM table order by id DESC")
simple enough

they come in order like this
cat 1
cat 2
cat 3

but 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 3
cat 1
cat 2

see 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 :(

#5 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 06 September 2006 - 03:44 AM

You would need to create a specific field (order_by) with which you can specify whatever order you want your records to appear. eg

id    order_by
__________________
1     3
2     6
3     1
4     5
5     2
6     4

Given th above example, the following query...

SELECT id FROM tbl ORDER BY order_by

would produce...

id
___________________
3
5
1
6
4
2

Does that help explain it?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users