Forum Moderators: open

Message Too Old, No Replies

Order by

trying to order alphabetically where it is split into a - b ect

         

onlinecasinospro

10:09 am on Feb 14, 2006 (gmt 0)



right. I know how i would go about ordering my reviews by name. But what i want to know is, is it possible to go about ordering the name to just a-b then c-d then e-f ect, so that it will be split of like: http://www.example.com/page.html
Basically i know i would have to use the

SELECT * FROM $tablename ORDER BY name (would i then do something like WHERE name="a"to"c" or something?)

I really hope this makes sense. i am a bit stuck as to how i could go about doing it. THANKS!

[edited by: txbakers at 11:41 am (utc) on Feb. 14, 2006]
[edit reason] no personal URLs [/edit]

tomda

10:27 am on Feb 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

Firstly, note that URL are not allowed in this forum. Please, read the term of service.

To get name starting with "a" and "b" use:
SELECT * FROM $tablename WHERE name LIKE "%a" OR name LIKE "%c" ORDER BY name;

Dijkgraaf

10:15 pm on Feb 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Tomda,
shouldn't that be
SELECT * FROM $tablename WHERE name LIKE 'a%' OR name LIKE 'c%' ORDER BY name
The way you have it, it is ending with rather than starting with :-)

The other way would be to have
select * from $tablename where left(name,1) in ('a','b','c') ORDER BY name

Possibly thats not what he is after though.
Do you mean that things are shown on a page grouped by letter?
Then all you need is a bit of logic in the loop that is retrieving the records, to put a break in when it changes on the boundry points you want.
Let us know if thats what you are after.

tomda

7:06 am on Feb 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dickgraaf,
Yeah you are right, sorry for that!