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 Link to comment https://forums.phpfreaks.com/topic/198896-check-records-in-table/ 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. Link to comment https://forums.phpfreaks.com/topic/198896-check-records-in-table/#findComment-1044197 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 Link to comment https://forums.phpfreaks.com/topic/198896-check-records-in-table/#findComment-1044393 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". Link to comment https://forums.phpfreaks.com/topic/198896-check-records-in-table/#findComment-1044636 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.