dannel77 Posted September 10, 2006 Share Posted September 10, 2006 Hi,I need help modifying this script so that it becomes possible to search multiple fields insteadof just one field. As it is now I can search for one specific word (within a table row) but if I try and make a search for 2 words *with another word in between* it doesn't work. Hope I make som sense.. :P$searchstring = trim($searchstring);// remove leading and trailing blanks// Nu bestämmer vi antal per sida och kollar upp totala antalet$limit = 30; // Antal per sida$where = "$chose LIKE '%$searchstring%' OR item LIKE '%$searchstring%' OR code_no LIKE '%$searchstring%'";$result = @mysql_query("SELECT COUNT(*) FROM products WHERE item LIKE '%$searchstring%' OR code_no LIKE '%$searchstring%'")or die("Error fetching number in DB<br>".mysql_error());$numrows = @mysql_result($result, 0); // Antal i databasen Quote Link to comment Share on other sites More sharing options...
onlyican Posted September 10, 2006 Share Posted September 10, 2006 Try thisif the string to search for is"Search String";then replace the space with a %so the query would look likeSELECT * FROM tablename WHERE fieldname LIKE '%search%string%' 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.