Hello everyone
I'm stuck again on Displaying images from a Database and I hope somebody will be able to help me.
Let me explain the scenario a bit:
- the images are uploaded through a PHP upload page which moves the images in a folder of my website
- at the same time the file name is inserted into a database:
table structure:
photo_id(mediumint, auto incremented, primary key)
photo_name (varchar 255, basicallly the $_FILES["file"]["name"])
inserting the image details into the database:
- $filename=$_FILES["file"]["name"];
2.
- $sql="INSERT INTO nimtaz_photos (photo_name) VALUES ('$filename')";
- if (!mysql_query($sql,$dbc))
- {
- die('Error: ' . mysql_error());
- }
So far so good:
- The image is saved on my website,
- the image name is stored in my database as imagename.jpg or imagename.gif
In my photos.php page I would like to display all the images in a while loop but I don't know how to point to the image name on the database from my page:
- <?php
- $query = "SELECT * FROM nimtaz_photo ORDER BY photo_id DESC";
3.
- $result = mysql_query($query);
5.
- while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
- echo "<img src='http://www.morenafiore.com/public/upload/".$row['photo_name']"'" />";
- }
- ?>
10.
I tried them all:
- echo "<img src='http://www.morenafiore.com/public/upload/$row['photo_name']'
- echo "<img src='http://www.morenafiore.com/public/upload/'$row['photo_name']''
- echo "<img src='http://www.morenafiore.com/public/upload/{$row['photo_name']}'
So I hope somebody can help me understanding what I'm doing wrong 🙁
Thank you all
Morena