How do I make my PHP thing list in name order?
It's listing by ID autonumber, but I want to have them listed by name, what should I do...
I'm only posting this cause I can't find Mike anywhere...
How do I make my PHP thing list in name order?
It's listing by ID autonumber, but I want to have them listed by name, what should I do...
I'm only posting this cause I can't find Mike anywhere...
If you're querying your data from a database, put:
order by name asc
at the end of your sql query, where name is the name of the column you want to sort by. Are you using a database?
....
I've got fluOriginally posted by incka
I'm only posting this cause I can't find Mike anywhere...
Don't you just love free internet games ?
Well cover your mouth when you type. I don't want to get sick!
Poor Mike...
This is the code I'm using minus the log in details...
PHP Code:
<?php
//connect
$connect = mysql_connect("localhost", "dbname", "password");
//select db
mysql_select_db("dbname", $connect);
//query db
$result = mysql_query("SELECT * FROM games WHERE Category='Adventure'", $connect);
//start table
echo ("<table>");
//list all games in table
for ($x=0; $x < mysql_num_rows($result); $x++)
{
$row = mysql_fetch_assoc($result) ;
echo ("<tr style='padding-top:10'>");
echo ("<td><a href='http://www.games2go.co.uk/game/");
echo $row['URL'];
echo ("'>");
echo ("<img src='");
echo $row['ImageURL'];
echo ("' border='0' width='70' height='59'>");
echo ("</a>");
echo ("</td>");
echo ("<td style='padding-left:10'><font color='000000'><b>");
echo ("<a href='http://www.games2go.co.uk/game/");
echo $row['URL'];
echo ("'>");
echo $row['Name'];
echo ("</font></a></b>");
echo (": ");
echo $row['Description'];
echo ("</td></tr>");
}
?>
incka, did you try my suggestion?
Code:$result = mysql_query("SELECT * FROM games WHERE Category = 'Adventure' order by Name asc", $connect);
....
I'll try it now... Before when you posted it I didn't know where to put it, but i understand now... I'll try it out when I get to my computer... Thank you
The "order by ____ ASC or DESC" is what you need (as mentioned earlier).
In case you're wondering, ASC is short for ascending and DESC is short for descending.
Never knew that
Don't you just love free internet games ?
Bookmarks