Click here to Skip to main content
15,889,491 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to select images from the database gallery but am failing below is my codes

<?php
include 'DBController.php';

$db_handle = new DBController();
?>
<!DOCTYPE html>
<html>

<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>

    <div id="gridview">
    <div class="heading">Image Gallery</div>
<?php

$query = $db_handle->runQuery("SELECT * FROM tbimages ORDER BY id ASC");
if (!empty($query)) {
    foreach ($query as $key => $value) {
        ?>  
            <div class="image">
            <?php 
                if(file_exists($query[$key]["path"])) 
                { 
				
            ?>
            <img src="<?php echo $query[$key]["path"] ; ?>" />
            <?php 
                } else { 
            ?>
            <img src="images/delivery.jpg" />
            <?php
                }
            ?>
            </div>
<?php
    }
}
?>
    </div>
</body>
</html>


What I have tried:

have tried to put echo
($query[$key]["path"]))
to see if the files exist in the database but am geting nothin..
my database gallary structure is
id
name
path
Posted
Comments
Richard MacCutchan 3-Dec-20 4:42am    
You need to use your debugger to see what is happening inside your DBController object.
[no name] 3-Dec-20 14:24pm    
I don't think this will "echo". (img src=...)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900