Another question for Magic (or any other PHP Programmer)

Forum Archive - from http://theuniversal.net
Locked
puggy
Posts: 92
Joined: Fri Apr 16, 2004 2:10 pm

Post by puggy »

are there any id's in the table?
Normally the first thing i add in a table is an id, that way i can find specific info. So in this case i would just use:

$query = "select * from users WHERE id='1' ";

if you adding into the DB table, to get the next id you can:

$query = "select MAX(id) from users";

then add 1 to that id
User avatar
Magicfinger
Staff
Staff
Posts: 1078
Joined: Tue Sep 30, 2003 10:38 am
Location: here,there and everywhere

Post by Magicfinger »

$sql=(SELECT * FROM users LIMIT 2 ORDER BY id DESC);

and to count the users

$numusers=mysql_query(SELECT COUNT (*) FROM users);
Locked