lovephp Posted November 3, 2012 Share Posted November 3, 2012 guys how do i do this $id = $_REQUEST[''id']; $name = $_SESSION[''name']; if(Name Exist In Field == "Matching With Requested ID" ){ echo "show results"; }else{ echo "error"; } Link to comment https://forums.phpfreaks.com/topic/270264-how-to-check-if-name-exist-in-the-sql-table-matching-with-id/ Share on other sites More sharing options...
berridgeab Posted November 3, 2012 Share Posted November 3, 2012 Do you wish to match the given data to a record in a database? Link to comment https://forums.phpfreaks.com/topic/270264-how-to-check-if-name-exist-in-the-sql-table-matching-with-id/#findComment-1390024 Share on other sites More sharing options...
lovephp Posted November 3, 2012 Author Share Posted November 3, 2012 yes thats right from database i want to match whether the name exist in table field with the id requested Link to comment https://forums.phpfreaks.com/topic/270264-how-to-check-if-name-exist-in-the-sql-table-matching-with-id/#findComment-1390031 Share on other sites More sharing options...
Pikachu2000 Posted November 3, 2012 Share Posted November 3, 2012 $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 } Link to comment https://forums.phpfreaks.com/topic/270264-how-to-check-if-name-exist-in-the-sql-table-matching-with-id/#findComment-1390033 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.