I'm trying to get the categories name from each array value from the database and then add the categories name to an array $cat_name
, how can I do this using PHP & MySQL?
$array = array(1, 2, 3, 4, 5);
$cat_name = array();
$dbc = mysqli_query($mysqli,"SELECT category
FROM categories
WHERE id = '" . $array . "'");
if (!$dbc) {
print mysqli_error($mysqli);
} else {
while($row = mysqli_fetch_array($dbc)){
$cat_name[] = $row['category'];
}
}