Printing Data from a dB in Reverse Order
Hey, what I'm trying to do is to either print data from a dB (MySQL) in reverse row order...in other words print row 5, row 4, etc...
OR insert new rows at the top of the table instead of underneath the old ones...knowwhadumsayin? I have no idea how to do this.
Thanks.
Abhishek Reddy posted this at 02:19 — 28th January 2004.
He has: 3,348 posts
Joined: Jul 2001
Look into
http://nz.php.net/manual/en/function.array-reverse.php
Mark Hensler posted this at 06:06 — 28th January 2004.
He has: 4,048 posts
Joined: Aug 2000
SELECT * FROM table ORDER BY auto_increment_field DESC
andrews_john posted this at 09:33 — 28th January 2004.
He has: 3 posts
Joined: Jan 2004
Maybe that's work (but it's a little bit harder than other variants): you may transfer your info to array, and then print array from end to beggining...
andrews john
http://www.softwareforhosting.com
mairving posted this at 13:08 — 28th January 2004.
They have: 2,256 posts
Joined: Feb 2001
As a general rule, it is always best to do your sorting in SQL since it is a bit quicker.
kb posted this at 00:59 — 29th January 2004.
He has: 1,380 posts
Joined: Feb 2002
what value does "auto_increment_field" take?
Mark Hensler posted this at 07:22 — 29th January 2004.
He has: 4,048 posts
Joined: Aug 2000
I meant, sort by a field that is the primary key with auto_increment (usually called "id").
kb posted this at 02:50 — 30th January 2004.
He has: 1,380 posts
Joined: Feb 2002
ok thanks
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.