sort

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

sort

Post by ol4pr0 »

how do i sort(); this query?

Code: Select all

// this is what i have now 
$result = mysql_query("SELECT pages, name FROM links");
while (list($pages, $name) = mysql_fetch_row($result)) {
    echo " \n" .
          "<a href="$pages?id=$name" target="I1">$name</a><br>\n" .
          "\n";
}
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

$result = mysql_query("SELECT pages, name FROM links ORDER BY pages");
or
$result = mysql_query("SELECT pages, name FROM links ORDER BY name");
or
$result = mysql_query("SELECT pages, name FROM links ORDER BY pages DESC");
or
$result = mysql_query("SELECT pages, name FROM links ORDER BY name DESC");

:o
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

You're certainly familiar with order by?

Edit: Gah, that happens when the phone rings. I didn't hit post until 20 minutes later ;)
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

dumb dumb dumb ... Of me..
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

No worries. First time I used mysql I started writing a bubble-sort algorithm in PHP, because I didn't know order by existed...;)

Best thing is to go nuts, throw yourself into a wonderfully hot whirlpool, sip a nice cocktail and watch the sunset.

Hell, that's what I want to do now, anyway.
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Well its 36 C in my country @ the moment.. ( only missing the cocktails @ work ehehehh )
Post Reply