PHP code:
$checked = $this->input->post('checkbox');
$status = $this->input->post('adsstatus');
if(in_array('all', $checked)){
$query = 'SELECT * FROM ads';
}
else{
$finalnumber = count($checked) - 1;
for($i = 0; $i < count($checked); $i++){
$query = 'SELECT * FROM ads WHERE ';
if($i == $finalnumber){
$query .= 'ID = $checked[$i] ';
}
else{
$query .= 'ID = $checked[$i] || ';
}
}
}
print_r($checked);
echo $query;
OUTPUT:
Array
(
[0] => electronics
[1] => kitchen
[2] => decoratives
[3] => homedecor
[4] => furnitures
[5] => toys
[6] => vehicles
)
SELECT * FROM ads WHERE ID = $checked[$i]
the string of variable $query is not joining together. the value of the variable checked is 7 it executing my nested else condition but still string is not joining together. How to resolve it please help me right now I am a helpless