I am trying to join 2 tables based on the id. I want to display the second table images to be displayed together in a single array
art_column {
id : 66
name : Test2
title : Art 2
image : null
art_work : {Penguins.jpg},{Tulips.jpg}
}
Table artcolumn stores id,name,image,title
Table artwork_images store a_id,art_work
Joining id and a_id i get the data but how can i store in array in the given format
Here is the code
$result = ("SELECT artcolumn.id,title, image,name,art_work FROM artcolumn JOIN artwork_images ON artwork_images.a_id = artcolumn.id") or die(mysqli_error());
$sql=mysqli_query($con,$result);
if (mysqli_num_rows($sql) > 0) {
// looping through all results items node
$response["artcolumn"] = array();
while ($row = mysqli_fetch_array($sql,MYSQLI_ASSOC)) {
// temp user array
$news = array();
$news["id"] = $row["id"];
$news["name"] = $row["name"];
$news["title"] = $row["title"];
$news["image"] = $row["image"];
$news["art_work"] = $row["art_work"];
array_push($response["artcolumn"], $news);
}
In my code id,name,title,images get repeated for second image also