Page 1 of 1

Searching through a MySQL db

Posted: Mon Jan 05, 2009 4:55 pm
by JKM
Hi there!

How can I check if $input isin field "xxx" (in any rows)? "if($input isin table "xxx" (in any rows)) { blabla }"

Re: Searching through a MySQL db

Posted: Mon Jan 05, 2009 6:27 pm
by it2051229
you do a mysql query like:

Code: Select all

 
$fieldQuery = mysql_query("SELECT field FROM table WHERE field LIKE '%xxx%'") or die(mysql_error());
 
if(mysql_num_rows($fieldQuery) > 0)
{
     print "Match Found";
}
else
{
    print "Match not found";
}