I am storing the IDs of names with implode() function and comma separated like 1,3. Column name is diet_id(varchar) and it has values 1,3. Now i want to fetch and display these IDs and their names like ID1 is ABC and ID2 is XYZ. I am using explode function to fetch and display but it returns me Array. Here is what i did so far
Fetching
<?php
$ShowProducts = mysqli_query($con, "SELECT * FROM food WHERE merchant_id='$userId'");
while($row=mysqli_fetch_assoc($ShowProducts)){
// Getting Names from IDs
$Diet_query = mysqli_query($con,"SELECT * FROM diets WHERE id=".$row['diet_id']);
$main_diet = mysqli_fetch_assoc($Diet_query);
$ar = explode(' ',$main_diet);
?>
Now displaying
<td><?php echo $ar;?></td>
but it returns me Array