Reputation: 15
I am looking to have the sql_query look into the Table and tell me in a $variable if the item is in the Table or not.
Am I going about this all wrong?
$string = mysql_query("SELECT * FROM Table WHERE Column = 'item'");
if ( $string == true ) {
$roger = "Found it!";
} else {
$roger = "Sorry dude!";
}
echo $roger;
Upvotes: 1
Views: 123
Reputation: 7596
Use mysql_num_rows()
http://www.php.net/manual/en/function.mysql-num-rows.php
$resource = mysql_query("SELECT * FROM Table WHERE Column = 'item'");
if ( mysql_num_rows($resource) > 0 ) {
$roger = "Found it!";
} else {
$roger = "Sorry dude!";
}
echo $roger;
Upvotes: 3