Searching through a MySQL db

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
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Searching through a MySQL db

Post 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 }"
User avatar
it2051229
Forum Contributor
Posts: 312
Joined: Tue Dec 25, 2007 8:34 pm

Re: Searching through a MySQL db

Post 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";
}
 
Post Reply