-1

i am trying display from the databaseand i want the file name then the img under how world i go about doing that this is my code and i flowed a website show us how to upload to the database and i just the add to it here is the link to it The website i ues

<?php
    // Include the database configuration file
    include 'dbConfig.php';

    // Get images from the database
    $query = $db->query("SELECT * FROM images ORDER BY uploaded_on DESC");

    if($query->num_rows > 0){
        while($row = $query->fetch_assoc()){
            $imageURL = 'uploads/'.$row["file_name"];
    ?>
        <img src="<?php echo $imageURL; ?>" alt="" />
    <?php }
    }else{ ?>
        <p>No image(s) found...</p>
    <?php } 
?>

this is my database layout is

CREATE TABLE `images` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `file_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 `uploaded_on` datetime NOT NULL,
 `status` enum('1','0') COLLATE utf8_unicode_ci NOT NULL DEFAULT '1',
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

1 Answers1

0

One possible method would be to use css pseudo-selectors in conjuntion with a pre-defined attribute of the image, such as dataset

<img data-filename="<?php echo basename( $imageURL );?>" src="<?php echo $imageURL; ?>" alt="" />


<style>
    [data-filename]:before{content:attr(data-filename)}
</style>
Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46
  • Thanks for the help I just try it and nothnig change no filename i added the data-filename the img still show up but no filename I am get the img form mysql database dose that make a difference – Santo Lewis Sep 23 '19 at 20:35