Hi all
Using the following example:
I have 4 images in the database each with an imagetypeid value.
e.g:
name | imagetypeid
image1.jpg | 1
image2.jpg | 2
image7.jpg | 2
image34.jpg | 5
Now I need to loop through the records and put them into an array which needs to be structured as such:
Array(
[1] => Array
(
[0] => image1.jpg
)
[2] => Array
(
[0] => image2.jpg
[1] => image7.jpg
)
[5] => Array
(
[0] => image34.jpg
)
)
You can see the first array KEY is the IMAGETYPEID value and then within that I have all the images associated to that imagetypeid.
Here is my PHP code which is currently not doing what I need:
while ($row = mysqli_fetch_array($res)) {
$image = $row['image'];
$typeid = $row['imagetypeid'];
$array[$typeid] = array($largeimage);
}
mysqli_free_result($res);
It is overwriting one of the record which shares the same imagetypeid.
Can someone provide an example of how I can fix this?
Many Thanks