How do i check if a user already exist i nmy table

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
pelegk
Forum Newbie
Posts: 5
Joined: Wed Sep 18, 2002 6:26 am

How do i check if a user already exist i nmy table

Post by pelegk »

i have a table with "userid'!
how can i check if the user id exist or not?
thanks i advance
peleg
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post by Coco »

i assuming that your talking about a mysql table...
check this out, should help you
http://www.mysql.com/doc/en/Retrieving_data.html

what you would be looking to do would be something like:

Code: Select all

$result = mysql_query("select idnumber from table1 where userid = $user");
if ($row = mysql _fetch_row($result)
    echo "username already used by {$rowї'idnumber']}";
else
{//stuff
}
you get the general idea... hopefully thats enough to get you going and learning... but no too much so as you dont learn at all
Post Reply