PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
kyleiwaniec
Forum Newbie
Posts: 14 Joined: Tue Jun 22, 2010 2:21 pm
Post
by kyleiwaniec » Thu Jun 24, 2010 3:22 pm
I have four large thumbnails on the right hand side of my page which are drawn from a directory.
Is there a way to associate a unique link with each image? (so that when you click on a image it takes you to its page)
http://www.mercercountyrealtors.com/pre ... index2.php
my php snippet, which BTW, I got from this forum,Thks.
Code: Select all
<?php
$files = glob("featured_images/*.*");
for ($i=0; $i<=3; $i++) {
$num = $files[$i];
//print $num."<br />";
echo '<li><img style="width:180px; height:140px; padding: 3px; margin:5px; border: 1px solid #ccc;" src="'.$num.'" ></li>'; }
?>
AbraCadaver
DevNet Master
Posts: 2572 Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:
Post
by AbraCadaver » Thu Jun 24, 2010 3:38 pm
I'm not sure if you've already built these pages or they will be built dynamically, but this is more dynamic:
Code: Select all
$id = (int)$num;
echo '<li><a href="property.php?id=$id">
<img style="width:180px; height:140px; padding: 3px; margin:5px; border: 1px solid #ccc;" src="$num">
</a></li>';
Then on the property.php page you use this to get the passed id:
mysql_function(): WARNING : This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
kyleiwaniec
Forum Newbie
Posts: 14 Joined: Tue Jun 22, 2010 2:21 pm
Post
by kyleiwaniec » Thu Jun 24, 2010 5:39 pm
It seems this will take me to the id on the page property.php.
What I'm trying to do is have each image link to its own page. So image1.jpg links to featured1.php, image2.jpg links to featured2.php, and so forth.
The pages will not be dynamically generated (for now).
However, I can name the pages sequentially, if that helps. (featured1.php, featured2.php, etc..)
Maybe I'm going about it the wrong way ?
kyleiwaniec
Forum Newbie
Posts: 14 Joined: Tue Jun 22, 2010 2:21 pm
Post
by kyleiwaniec » Thu Jun 24, 2010 6:11 pm
OK, I think I'm getting it. The property.php page will contain only the image I clicked on (and hopefully other associated data).
pardon my ignorance, is that right?
But then I'll have to make my whole website dynamic and I'm not really knowledgeable enough to do that.
kyleiwaniec
Forum Newbie
Posts: 14 Joined: Tue Jun 22, 2010 2:21 pm
Post
by kyleiwaniec » Thu Jun 24, 2010 6:52 pm
OK, I got what I was looking for:
Code: Select all
<?php
$files = glob("featured_images/*.*");
for ($i=0; $i<=3; $i++) {
$num = $files[$i];
//set target path for image
$path = "featured" . $i . ".php";
//print $num."<br />";
echo '<li><a href='.$path.'><img style="width:180px; height:140px; padding: 3px; margin:5px; border: 1px solid #ccc;" src="'.$num.'" ></a></li>';
}
?>
Thanks for all your help