robert_gsfame Posted April 18, 2010 Share Posted April 18, 2010 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 Quote Link to comment Share on other sites More sharing options...
fenway Posted April 18, 2010 Share Posted April 18, 2010 Don't store delimited values in a single field. Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted April 19, 2010 Author Share Posted April 19, 2010 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 Quote Link to comment Share on other sites More sharing options...
fenway Posted April 19, 2010 Share Posted April 19, 2010 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". Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.