Reputation:
I have some thumbnail images with its larger version.I placed the thumbnail images in a page.Now for link I just gave a link
<a href="image/largerimage1.jpg"><img src="thumbnail1.jpg></a>
but for this I have to make different pages for showing larger one.I want to give a link to show them in a single page.means whenever I will click the thumbnail it will open the larger one in a page with the same url but with its name like
imagegallery.php?news=images/largerimage1/13.jpg
imagegallery.php?news=images/largerimage1/14.jpg
so how to do that?
Upvotes: 0
Views: 323
Reputation: 4371
Pretty basic stuff, I suggest you get to read some PHP tutorials on the internet to get some knowledge on one thing and another.
The ?news=
part in your URL is a parameter that can be read by PHP. This type is known as $_GET
. To get this part you would need $_GET['news']
so if we'd use your first link and place this inside a script: echo $_GET['news'];
the page would say images/largerimages1/13.jpg
.
In order to get the image loaded on your website we need some simple steps, I'm changing the news
parameter into image
, that suits better for your script since it ain't news items:
<?php
// Define the path (used to see if an image exists)
$path = 'your/absolute/path/to/public_html/'; # or wwwroot or www folder
// First check if the parameter is not empty
if($_GET['image'] != "") {
// Then check if the file is valid
if(file_exists($path . $_GET['image'])) {
// If an image exists then display image
echo '<img src="'. $_GET['image'] . '" />;
}
}
?>
Below this script you can put all your thumbnails the way you want. Ofcourse, also for these thumbnails there are some automated options. But I strongly suggest you get a good look at the script above and some beginner PHP tutorials so you completely understand the example given. This still isn't the best method, but it's kicking you in the right direction.
Upvotes: 1
Reputation: 26861
I don't understand which part you don't know how to do:
- the link part?
it should look like
<a href="imagegallery.php?news=images/largerimage1/13.jpg"><img src="thumbnail1.jpg></a>
- or the PHP part (the file called imagegallery.php)?
Upvotes: 0
Reputation: 890
maybe you can something like this,
Techincally, there is no thumbnail image, just a stretch version of the regular image
Upvotes: 0
Reputation: 1
if your imagegallery.php is in root of your domain, you can just add slash as a first char to links like this:
<a href="/image/largerimage1.jpg"><img src="thumbnail1.jpg></a>
else you will have to write some php function which it returns BaseUrl of your web. Then it should looks like this:
<a href="<?php echo getBaseUrl(); ?>/image/largerimage1.jpg"><img src="thumbnail1.jpg></a>
Upvotes: 0