OutOfInk Posted April 11, 2014 Share Posted April 11, 2014 I havew populated $llec as an array with nine teams and i need to extract all users who have bet on any of these options, ive tried everything i can think of so far so if someone has a solution would be awesome. Ive tried a for () statement as well with no luck. $i = 0; $puntBets = mysql_fetch_row(mysql_query("SELECT `name` , `bet` FROM `tablebets` WHERE `placed_on` = '$llec[$i]' AND `round` = '$round'")); $i++; Link to comment https://forums.phpfreaks.com/topic/287697-arrays-in-a-mysql-statement/ Share on other sites More sharing options...
mac_gyver Posted April 11, 2014 Share Posted April 11, 2014 you would implode the array to make it a comma separated list and use an IN() comparison in the query - http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_in Link to comment https://forums.phpfreaks.com/topic/287697-arrays-in-a-mysql-statement/#findComment-1475770 Share on other sites More sharing options...
OutOfInk Posted April 11, 2014 Author Share Posted April 11, 2014 Thanks mac_qyver, I've imploded them as so $imp = implode("', '", $llec); But mysql is still saying theirs an error with my array data SELECT `name` , `bet` FROM `table` WHERE `round` = '$round' AND `placed_on` IN ('Richmond','Carlton','Port Adelaide','GWS Giants','Hawthorn','West Coast','North Melbourne','Draw','Draw') I run this as a test and it said theirs a error Link to comment https://forums.phpfreaks.com/topic/287697-arrays-in-a-mysql-statement/#findComment-1475771 Share on other sites More sharing options...
mac_gyver Posted April 11, 2014 Share Posted April 11, 2014 knowing what error you got would help. Link to comment https://forums.phpfreaks.com/topic/287697-arrays-in-a-mysql-statement/#findComment-1475772 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.