OK, I'm somewhat new to php, and even newer to these forums. I'm trying to put together an image gallery for my website.
So far I have set up a MySQL database on my domain host with info, I can query that database to display the thumbnail images, send the URL for each full-size image to an iframe for display when the user clicks on a thumbnail image, and I have a PHP DIV set up that I would like to display the image description in (pulled from the MySQL table). I'm trying to figure out a way to set up a variable that will store the URL from the iframe, then use basename() to strip out the filename of the image to use for calling to the database to get the image description.
Everything works except setting up the variables to use for retrieving the description as it is sent to the iframe. I can't figure out where to go from here. I would like to stay away from javascript and find a pure PHP solution, but I don't quite know how to proceed with this. Any ideas?
The initial PHP for displaying the thumbnail images is:
<?php
$sql = "SELECT * FROM data WHERE category LIKE '%foo%'";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)) {
echo "<div style='float:left;'>";
echo "<a href='http://example.com/images/".$row['img']."' target='frame1'><img
src='http://example.com/thumbs/".$row['thumb']."'></a>";
echo "</div>";
}
?>
The iframe code is:
<iframe src='' name='frame1' title='gallery image' scrolling=no width=400 height=400>
<p>Alternate HTML here for non-supporting browsers.</p>
</iframe>
The PHP DIV code is:
<?php
echo "<div style='width:400px; float:left;'>";
$query = "SELECT description FROM data WHERE image = 'foo_name'";
$result=mysql_query($query);
$row = mysql_fetch_assoc($result);
echo $row['description'];
echo "</div>";
?>
Any help is appreciated.