Click to See Complete Forum and Search --> : Create clickable image gallery
ljcharlie
10-23-2003, 03:02 PM
Is there a way to send a value from a photo gallery web page to a PHP page? Here's my situation. I want to create a photo gallery that a user can click on the thumbnail image and then a PHP page with the enlarge photo will display. The PHP page that have the enlarged photo also have a Javascript that alows the user to click the Next/Previous and Automatic button to load the image without loading a .html file that contains the enlarged photo. However, here's the problem. I want the PHP page to first load the enlarged version of the image that was clicked on the thumbnail page. And to do this, I have to pass a value from the thumbnail page to the PHP page so I can determine which image was clicked and load the enlarged version of that image to the PHP page. So I guess the question is, how do I pass a value from thumbnail page to the PHP page?
Any help is greatly appreciated!
Thank you,
ljCharlie
Just pass the value through the query string and use $_GET to parse it off on the PHP page. Like this, for instance:
<a href="yourpage.php?image=foo.jpg">foo</a>
and the PHP page:
$image = $_GET['image'];
echo $image; # will echo foo.jpg
ljcharlie
10-23-2003, 06:14 PM
Thank you very much for your help. Just to clarify if I got it right. All my thumbnails have to be in a <Form></Form> and my code on the link is
<a href="photoEnlarged.php"><img src="photos/lp0001.jpg" width="100" height="67" border="0">Photo1</a>
for it to work, correct? I use this code then that means the Photo1 name will show up as a link, correct?
ljCharlie
ljcharlie
10-23-2003, 06:21 PM
I have tried this:
<a href="photoEnlarged.php?img src="photos/lp001.jpg"">Photo1</a>
and the thumbnail doesn't show only the word "Photo1" is shown.
ljCharlie
No, you have it a bit wrong... Try this:
<a href="yourpage.php?image=foo.jpg">foo</a>
and:
<?PHP
$image = $_GET['image'];
echo "<img src=\"$image\">";The code you posted:
<a href="photoEnlarged.php?img src="photos/lp001.jpg"">Photo1</a>
doesn't work because of the quotes (and I wouldn't use the img src= part)
ljcharlie
10-23-2003, 09:34 PM
Perfect! It works! Many thanks for your help. I'm greatly appreciate your help.
However, if you don't mind. I have one more question. How do I make a button when click launch a page?
Here's what I have.
<input type="button" name="Home" value="Home" onClick="photoAlbum.html">
However, this doesn't work. If you would be so kind as to help me with this problem too.
Thank you,
ljCharlie
<form action="somepage.php" method="post" target="_blank">
<p><input type="hidden" name="picture" value="yourpicture.jpg">
<input type="submit" value="go"></p>
</form>
And then on somepage.php, use this:
<?PHP
$image = $_POST['image'];
echo "<img src=\"$image\">";
?>Also note the target="_blank" has been depreciated, so you'll want to use the transitional DOCTYPE (http://www.alistapart.com/articles/doctype/).
ljcharlie
10-23-2003, 09:47 PM
Again, thank you. Unfortunately, I already have a submit button. Can I have this button not relying on the form action property and just launch a page?
ljCharlie
The reason I posted the above is because that will continue to function for users without JavaScript. You could do it like this, but be sure you have an alternate way for users to get to the page, as it will fail for the 13% without JavaScript enabled:
<input type="button" value="go" onclick="window.open('yourpage.php','newwin','height=300,width=400');">
ljcharlie
10-23-2003, 10:21 PM
Many thanks for the help. I got it working now.
ljCharlie