I have a table called "images" in a mySQL database. There are 7 rows and 2 columns in this table. The columns are: "id" and "image" (BLOB type). I want to echo all images from this table as an array.
This is the code I tried to use:
<?php
$link = mysqli_connect("localhost", "xxxx", "xxxx", "xxxx");
if(mysqli_connect_error()) {
die ("Error message");
}
mysqli_query($link, $query);
$query = "SELECT image FROM images";
$i = 1;
if ($result = mysqli_query($link, $query)) {
while ($row = mysqli_fetch_array($result)) {
${"image".$i} = $row['image'];
$i++;
}
$array = array($image1, $image2, $image3, $image4, $image5, $image6, $image7);
echo json_encode($array);
}
?>
I'm getting a blank page when I run this code.
I really appreciate if you could give me any ideas of how I can fix this.
Just to explain why I need to echo these images as an array: I'm going to use AJAX in a JS file to put these images in specific divs in another HTML file.