Where In dengan dalam CI dari Looping data
Codeigniter 2022-02-01
if ($status != null) {
if ($status == 'Outstanding') {
$cek = $this->db->query("SELECT * FROM remark where status_case='Outstanding'");
foreach ($cek->result() as $row) {
$list[] = $row->remark_id ;
}
$this->db->where_in('remark_id',$list);
} else if ($status == 'Receiving') {
$cek = $this->db->query("SELECT * FROM remark where status_case='Receiving'");
foreach ($cek->result() as $row) {
$list[] = $row->remark_id ;
}
$this->db->where_in('remark_id',$list);
}
}
mysql where in array
-- SQL
SELECT * FROM table WHERE column IN('value1','value2','value3')
-- Javascript
$string="1,2,3,4,5";
$array=array_map('intval', explode(',', $string));
$array = implode("','",$array);
$query=mysqli_query($conn, "SELECT name FROM users WHERE id IN ('".$array."')");