07-20-2007, 12:50 PM
[eluser]Peter Goodman[/eluser]
What this does is it creates an array of question marks, implodes and hence comma separates them and puts them into the query, then lets CI substitute the real values in for each question mark.
Code:
$qs = array_pad(array(), count($_POST['SubArea']), '?');
$sql = "SELECT * FROM some_table WHERE subarea IN (". implode(',', $qs) .")";
$this->db->query($sql, $_POST['SubArea']);
What this does is it creates an array of question marks, implodes and hence comma separates them and puts them into the query, then lets CI substitute the real values in for each question mark.