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. Quote Link to comment 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%'"); Quote Link to comment 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 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.