wee493 Posted October 10, 2009 Share Posted October 10, 2009 I have a table like the following. Content | Value google1 | 1 yahoo1 | 2 google2 | 1 facebook1 | 3 google3 | 1 facebook2 | 3 I need to do something like $sql = mysql_query("SELECT * FROM table WHERE value = '1' OR value = '2'"); Thats fairly simple, but I have a user login system where users can specify what data they want to see (Basically it's not always going to be pulling data where value = 1 or 2). So I am puling the values from the users profile and I need to know how I would transform an array of number into a WHERE value = '1' OR value = '2'" statement. Link to comment https://forums.phpfreaks.com/topic/177175-sql-select-from-where-value-array/ Share on other sites More sharing options...
trq Posted October 10, 2009 Share Posted October 10, 2009 $a = array(2,4,5,6); $sql = "SELECT * FROM tbl WHERE fld IN(" . implode(',',$a) . ");"; Link to comment https://forums.phpfreaks.com/topic/177175-sql-select-from-where-value-array/#findComment-934192 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.