/    Sign up×
Community /Pin to ProfileBookmark

Create clickable image gallery

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

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@pyroOct 23.2003 — 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:

[code=php]$image = $_GET['image'];
echo $image; # will echo foo.jpg[/code]
Copy linkTweet thisAlerts:
@ljcharlieauthorOct 23.2003 — Thank you very much for your help. Just to clarify if I got it right. All my thumbnails have to be in a [COLOR=blue]<Form></Form>[/COLOR] and my code on the link is

[COLOR=blue]<a href="photoEnlarged.php"><img src="photos/lp0001.jpg" width="100" height="67" border="0">Photo1</a>[/COLOR]

for it to work, correct? I use this code then that means the [COLOR=blue]Photo1[/COLOR] name will show up as a link, correct?

ljCharlie
Copy linkTweet thisAlerts:
@ljcharlieauthorOct 23.2003 — I have tried this:

[COLOR=blue]<a href="photoEnlarged.php?img src="photos/lp001.jpg"">Photo1</a>[/COLOR]

and the thumbnail doesn't show only the word "Photo1" is shown.

ljCharlie
Copy linkTweet thisAlerts:
@pyroOct 24.2003 — No, you have it a bit wrong... Try this:

<a href="yourpage.php?image=foo.jpg">foo</a>

and:

[code=php]<?PHP
$image = $_GET['image'];
echo "<img src="$image">";[/code]
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)
Copy linkTweet thisAlerts:
@ljcharlieauthorOct 24.2003 — 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.

[COLOR=blue]<input type="button" name="Home" value="Home" onClick="photoAlbum.html">[/COLOR]

However, this doesn't work. If you would be so kind as to help me with this problem too.

Thank you,

ljCharlie
Copy linkTweet thisAlerts:
@pyroOct 24.2003 — <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:

[code=php]<?PHP
$image = $_POST['image'];
echo "<img src="$image">";
?>[/code]
Also note the target="_blank" has been depreciated, so you'll want to use the transitional [url=http://www.alistapart.com/articles/doctype/]DOCTYPE[/url].
Copy linkTweet thisAlerts:
@ljcharlieauthorOct 24.2003 — 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
Copy linkTweet thisAlerts:
@pyroOct 24.2003 — 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');">
Copy linkTweet thisAlerts:
@ljcharlieauthorOct 24.2003 — Many thanks for the help. I got it working now.

ljCharlie
Copy linkTweet thisAlerts:
@pyroOct 24.2003 — Sure thing... ?
×

Success!

Help @ljcharlie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...