|
-
Sep 18th, 2001, 04:00 PM
#1
PHP and mySql question..
Ok,
Say I have a mySql database called MyDB and a table called MyTBL. It contains a persons name, age and an id for them. Like so:
1 Peter 33
2 Jason 36
3 Mickey 49
My question is, can someone give me a snippet of code that would access that db and tbl, then retrieve all entires, display them in a table one by one but is ordered by age, youngest first?
Muchly Appereciated,
Cheeko
-
Sep 18th, 2001, 08:34 PM
#2
well this is a shot in the dark as I have not tested it to see if it works.
PHP Code:
mysql_connect(location, username, password) or die("error opening the MySQL server");
mysql_select_db(MyDB) die("error opening the MySQL Database");
$result=mysql_query("select * from MyTBL " order by age desc") or die("error querying the MySQL table");
while ($row = mysql_fetch_array($result)) {
echo $row["id"] $row["name"] $row["age"];
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|