I am pretty new to PHP. As a way to learn PHP and MySQL I am working on a database that will store filenames of images and attach tags to them. I would like to be able to search for a tag and see a list of images that have that tag. My plan is to display the thumbnails in an html table and them click the thumbnail to see the full image. In the long run, I am doing this for a church for them to be able to keep track of the images they use in their events and so I am working on some fairly dated hardware.
I have a Windows XP system that I am running a WAMP 2.2 server. I am up to date on all the windows updates. This is the information from the info script posted in the FAQs:
PHP Version: 5.3.8
Display Errors: On
Error Level: Not E_ALL
Register Globals: Off
OK, so here is my problem. I store the file name in the database. (I have tried to store either the full path or just the filenname, I get the same problem either way.) I do a query from my database to get the thumbnail filename. These are returned in a mysqli result object. Then I am doing a foreach loop to display the thumbnails. My goal is to do this in an html table. However, right now I can not display the images so I haven't even got to building the table yet.
My plan was to have a folder (e.g. c:\images) that had a folder for thumbnails and a folder for images. However, I could not display the images so I moved the folder to the root folder of the website. I still can not display the images.
Here is my code:
Code: Select all
<?php
require_once ("common.inc.php");
?>
<html>
<head></head>
<title>Database test</title>
<body>
<h1>Image database</h1>
<p>This is a test of how to show images from the database.</p>
<?php
$conn = new connection("images", myUserName, db_password, "localhost");
$mysqli = $conn->connect();
$thumbnail = new image();
$result = $thumbnail->getAllThumbnails($mysqli);
while ($row = $result->fetch_assoc()) {
printf('<img src="http://localhost/images/thumbs/%s" />', $row["thumb"] );
echo $row["thumb"].'<br />';
//echo '<img src="images\\thumbs\\'.$row["thumb"].'" /><br />';
}
?>
<!-- try to access an image directly -->
<img src="images/thumbs/tn_image1.jpg" />
</body>
</html>If I have the image in the root directory of the webpage, then the image will display e.g.:
Code: Select all
<img src="filename.jpg" />
Code: Select all
<img src="images/filename.jpg" />
I am really stumped with this and I think it should be simple. Thanks in advance for the help.

