Jump to content

check records in table


robert_gsfame

Recommended Posts

i have let say table1 with this kind of record  "James, King, Ronald, Steve" inside the column created

 

and i want to check whether what user want is there...therefore i use this query

 

 

$check=mysql_query(sprintf("SELECT * FROM table1 WHERE column LIKE '%%{$userinput}%%'",

mysql_real_escape_string($userinput)));

 

$numrows=mysql_num_rows($check);

if(empty($numrows)){

echo "no result";}else{

echo "yes it's there";}

 

 

when i put cheryl and start searching it then i will have the correct answer which is "no result"....but when i put only one letter "a" then i'll get "yes it's there"

 

I wish to have "yes it's there" output only when user type James, or King or Ronald or Steve

 

how can i do that? thx

Link to comment
Share on other sites

i try using FULLTEXT but i get the error when count the record using mysql_num_rows

so instead of using it, i use REGEXP and it works

No, it doesn't -- just wait until you input has a comma, or you have "John" and "Johnson".

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.