checking if a MySQL record exists

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
pb2ya
Forum Commoner
Posts: 42
Joined: Sat Jul 06, 2002 5:20 pm
Location: ATL
Contact:

checking if a MySQL record exists

Post by pb2ya »

how can you check if a record exists, just post the query and it will be greatly appreciated
User avatar
RandomEngy
Forum Contributor
Posts: 173
Joined: Wed Jun 26, 2002 3:24 pm
Contact:

Post by RandomEngy »

Code: Select all

$result = mysql_query("SELECT * FROM tablename WHERE <conditions>");
$num_results = mysql_num_rows($result);
if( $num_results == 0 )
  echo "No results found";
else
  echo "Results found";
pb2ya
Forum Commoner
Posts: 42
Joined: Sat Jul 06, 2002 5:20 pm
Location: ATL
Contact:

ok thx

Post by pb2ya »

thanx a lot. sry for askin yall all these questions, when i finish my script, ill give it 2 yall.
Post Reply