Skip to main content
gamedev.net
🔒 Locked 🤖 Godot

Mysql/PHP Sort

Started by Cygnus_X Jul 14, 2004 at 10:51 AM 5 replies 400+ views
Original Post
Cygnus_X
Cygnus_X
I almost feel like my IQ is dropping a point or two just by asking.... but I'm trying to pull data from a mysql database useing php, and the code looks something like this. $r = mysql_query("select * from table order by cost asc"); The problem is, when I try to display the values of $r, it doesn't really sort by cost.... it only looks at the first number, and sorts by that instead of sorting by the entire thing. For example, the sort order will look something like: 10000 2 300 350000 4500 This, to me, is absurd. Is there any way to get it to actually sort by value? Or is this just a mysql bug? Or am I just overlooking something easy? Thanks in advance.
acraig
acraig
What is the column definition for 'cost'?
Cygnus_X
Cygnus_X
Its int(11) not null
Cygnus_X
Cygnus_X
well, i have:

$r = mysql_query("select * from table order by cost asc");

I then do:

for($i=0; $row = mysql_fetch_array($r); $i++)
{

echo $row['cost'].'';

}

(slashes were added for obvious reasons)

and it gives me what I posted earlier. I really find it quite strange.
Cygnus_X
Cygnus_X
Never mind... I've figured it out.... I had a syntax problem. But thanks for the help : )

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.