Jump to content

How To Check If Name Exist In The Sql Table Matching With Id?


lovephp

Recommended Posts

$query =  "SELECT COUNT(1) FROM table WHERE id = $id AND name = '$name'";
if( $result = mysql_query($query) ) {
 $array = mysql_fetch_row($result);
 if( $array[0] === 1 ) {
	  // name and id exist
 } else {
	  // name and id don't exist
 }
} else {
 // query resulted in an error
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.