I was just wondering if there was a better way to write this block of code in php. I have a string with values separated by commas. I need to prepare that string to pass it on to the query using IN clause.
$sql = "SELECT domain, items FROM rep_skills WHERE report_id = $id ";
$data = $conn->query($sql)->fetch_object();
while($data){
// can this be done in one line?
$array = explode(",",$records['items']$data->items); // string here is 39,40,41
$items = implode("','",$array); // string here is '39'39','40','41''41
// end of block
$query $result = $conn->query("SELECT description
FROM ".$tables[$data->domain]."
WHERE item_id IN ('".$items."')";");
$description = '';
while($row = $result->fetch_object()){
$details .= '- '.$row->description;
}
}