Forum Moderators: coopster

Message Too Old, No Replies

How to sort backwards...?

if ($sort == "price DESC") {print "<B>Price</b>";}

         

ncsuk

11:01 am on Jul 18, 2003 (gmt 0)

10+ Year Member



Hey guys bet you never thought youd see me in here seens I cant write PHP (although I learnt in last 3 days :) )

Basically I have a sort function as below

if ($sort == "price DESC") {print "<B>Price</b>";}

What I want to do is list the cheapest first. This query obviously just outputs the top amount first because thats the default. Can someone give me the code to turn it around or some info so I can figure it out myself and learn something?

Gaz

dmorison

11:02 am on Jul 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I presume that $sort is used elsewhere to build an SQL query; in which case you should be able to just drop the "DESC", since "ASC"ending is the default sort order.

ncsuk

11:03 am on Jul 18, 2003 (gmt 0)

10+ Year Member



Yeah it querying a mysql database so basically if I take the DESC bit out it will sort it the other way?

dmorison

11:05 am on Jul 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Should do.

ncsuk

11:19 am on Jul 18, 2003 (gmt 0)

10+ Year Member



Yup that worked (Kinda)

Thanks Dave