function find_image_by_id() {
    global $connection;
    $query = "SELECT * ";
    $query .= "FROM images ";
    $query .= "WHERE page_id={$_GET["page"]}";
    $image_set = mysqli_query($connection, $query);
    confirm_query($image_set);
    return $image_set;
}
function display_image_by_id(){
    $current_image = find_image_by_id();
    while($image=mysqli_fetch_assoc($current_image)){
        $output = "<div class=\"images\">";
        $output .= "<img src=\"images/";
        $output .= $image["ilink"];
        $output .= "\" width=\"72\" height=\"72\" />";
        $output .= $image["phone_name"];
        $output .= "</div><br />";
    }
    mysqli_free_result($current_image);
    return $output;
}
This is the code I'm using to show the images stored as links in mysql and the images are in a folder. But what happens after this code is executed only the second value is displayed. I want both value/ images to be displayed.
Try something like that-
All you need to do is just initialize this variable outside the loop.
 $output =''; //initialize before
SO your function look like this -
function display_image_by_id(){
    $current_image = find_image_by_id();
    $output =''; //initialize before
    while($image=mysqli_fetch_assoc($current_image)){
        $output .= "<div class=\"images\">";
        $output .= "<img src=\"images/";
        $output .= $image["ilink"];
        $output .= "\" width=\"72\" height=\"72\" />";
        $output .= $image["phone_name"];
        $output .= "</div><br />";
    }
    mysqli_free_result($current_image);
    return $output;
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With