Hello, I can't display images from database.
I have folder called "images" next to index.php where I keep images.

I suppose I have wrongly defined folder path with images or sth else.

        $connection = new mysqli("localhost", "root", "", "crud");
        $sql = "SELECT * FROM test";
        $res = $connection->query($sql);

        if(@$res->num_rows > 0)
            while($row = $res->fetch_assoc())
                <img src="<?php "C:/xampp/htdocs/img_mysql/images/".$row['image'] ?>" style="width:170px;height:120px" />

I put picture with how look my website when I try display images.

 ![011.jpg](/attachments/large/4/cb5cff474c596085beba1a63f9b6c6b6.jpg "align-center") 

Recommended Answers

All 3 Replies

You need to put echo inside the php before the path.

Also you should be supplying a relative path and not exposing your file structure. If the root of your server is img_mysql your path should start with images

You want URL and not path. I suppose you could try
echo 'http://localhost/img_mysql/images/' . $row['image'].

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.