spillage Posted May 6, 2008 Share Posted May 6, 2008 Hi, I have this small query in my page: mysql_select_db("promo", $con); $result = mysql_query("SELECT * FROM email WHERE printer LIKE '$printer'"); while($row = mysql_fetch_array($result)) My date base has a field called 'printers' and has data similar to 'hp,epson'. What I am struggling with is why this query is only pulling from the db line where 'printers' is only a single input. If $printers = 'hp' then 'hp,epson' is not echoed but 'hp' will be. Spent a couple hours trying diffrent things both google and referencing a couple of books but have hit a brick wall. Any help would be appriciated. Cheers, Noobie Spill. Link to comment https://forums.phpfreaks.com/topic/104406-solved-problem-with-query-noobie/ Share on other sites More sharing options...
rhodesa Posted May 6, 2008 Share Posted May 6, 2008 you need to tell it to allow characters on either side with a % $result = mysql_query("SELECT * FROM email WHERE printer LIKE '%$printer%'"); Link to comment https://forums.phpfreaks.com/topic/104406-solved-problem-with-query-noobie/#findComment-534481 Share on other sites More sharing options...
spillage Posted May 6, 2008 Author Share Posted May 6, 2008 Cheers, Really feel like an idiot as sure I tried this and keep getting an error. But all works now. Thanks Spill Link to comment https://forums.phpfreaks.com/topic/104406-solved-problem-with-query-noobie/#findComment-534510 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.