I have a search set up where people can search results based upon keyword, using the LIKE query. It works half of the time,..why? For instance.. if i search by keyword and search "When" I get about 30 results. When I search say, Celtics, or Botox, even though i know there are results, I get nothing? any ideas? IM using PHP Thank You, -Tim
Where does 'When' and 'Celtics' exist in the column string? Like with a '%' behind the text will only match words before the '%'. Like with a '%' in front and behind will find rows that have the word anywhere in the string (however this is slower since you'll have to read the entire table or index).
Can you post the database structure and SQL statement? Also, PHP is the scripting language. You are probably using MySQL on the backend, correct?
There could be a few factors causing your problem. But it is hard to tell without seeing thr actual code for myself. Be sure that you have correctly made the MYSQL (or other database query), it should look like this: "$sql = mysql_query("SELECT * FROM table_name WHERE column_name LIKE value%"); while ($row = mysql_fetch_row($sql)) { echo "$row[0] $row[1] $row[2] <br />"; } " Make sure you are using * instead of a preset value so that the search with query the entire database. You may also want to try adding a wild card character searches. You can do this by adding some underscores after value. The amount of underscores relates to the amount of wildcard characters. e.g: "value____" It may be possible that the results that are not showing contain a % character. If so try changing your end query to this: $sql = mysql_query("SELECT * FROM table_name WHERE column_name LIKE value\%"); An escape slash in front of the % character. Let me know if anything works.