fonecave Posted November 25, 2008 Share Posted November 25, 2008 Hi Guys, I am trying to run a mysql query in PHP, I need it to select all field in the products table where it matches a variable to the string in a field in the table AND the other where statement in there... Could i do something like this? ----- ALSO THIS NEEDS TO BE CASE IN-SENSITIVE $query = "SELECT * FROM products WHERE availability ='A' AND instr(['search_terms'],'test')<>0"; Link to comment https://forums.phpfreaks.com/topic/134274-php-query-help/ Share on other sites More sharing options...
DeanWhitehouse Posted November 25, 2008 Share Posted November 25, 2008 So you want to get all the records that have the a certain word any where in them like? tester has the word test in it or i am a tester testing this test has the word test in it once? If the latter then you can use the SQL clause LIKE Link to comment https://forums.phpfreaks.com/topic/134274-php-query-help/#findComment-699012 Share on other sites More sharing options...
flyhoney Posted November 25, 2008 Share Posted November 25, 2008 Maybe you should look into using "LIKE". <?php $query = "SELECT * FROM products WHERE availability ='A' AND description LIKE '%".mysql_real_escape_string($product_description)."%'"; ?> Link to comment https://forums.phpfreaks.com/topic/134274-php-query-help/#findComment-699014 Share on other sites More sharing options...
revraz Posted November 25, 2008 Share Posted November 25, 2008 FYI, by default, it is. ALSO THIS NEEDS TO BE CASE IN-SENSITIVE Link to comment https://forums.phpfreaks.com/topic/134274-php-query-help/#findComment-699024 Share on other sites More sharing options...
fonecave Posted November 26, 2008 Author Share Posted November 26, 2008 Thanks matey, Ill give it a go and see if it does the job! Thanks Link to comment https://forums.phpfreaks.com/topic/134274-php-query-help/#findComment-699755 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.