php dynamic url??
Posted: Fri May 15, 2009 2:12 pm
Hi All I am new php programmer and new to this forum. In the code I can not understand how it
echo "<td><a href=\"$scriptname?page=$page&photo=" . urlencode($image) . "\"><img src=\"" . $thumb->Thumblocation.$thumb->Thumbprefix.$image. "\" border=\"0\"></a></td>";
works?
The program is a simple image gallery where you click on a thumbnail and the large picture appears.
I will appreciate any sort of help. Thanks all.
echo "<td><a href=\"$scriptname?page=$page&photo=" . urlencode($image) . "\"><img src=\"" . $thumb->Thumblocation.$thumb->Thumbprefix.$image. "\" border=\"0\"></a></td>";
works?
The program is a simple image gallery where you click on a thumbnail and the large picture appears.
I will appreciate any sort of help. Thanks all.
Code: Select all
// Initialize thumbnail class
$thumb = new thumbnail;
// Options for EasyPhpAlbum Lite
$thumb->Thumbsize = 140; // The max. width or height
$thumb->Framewidth = 10; // The frame width around the photo
$thumb->Shadow = true; // Drop a shadow around the thumbnail
$thumb->Backgroundcolor = '#FFFFFF'; // The background color (needed for the sahdow effect)
$thumb->Framecolor = '#FFFFFF'; // The frame color
$thumb->Chmodlevel = '0755'; // The chmod level for saving the thumbnails
$thumb->Thumblocation = 'thumbs/'; // The directory path for the thumbnails
$thumb->Thumbprefix = 'thumb_'; // The prefix for the thumbnails
$tableformat = '3x3'; // The table size: columns x rows
// This scripts name
$scriptname=basename(__FILE__);
if ($scriptname=='') {$scriptname='index.php';}
// Read all image files in directory
$images=array();$newthumbs=array();
if ($dir=@opendir('./')) {
while ($filename=@readdir($dir)) {
if (($filename!='.') && ($filename!='..') && !is_dir($filename)) {
$extension=strtolower(substr($filename,strrpos($filename,'.')+1,strlen($filename)));
if ($extension=='jpg' || $extension=='jpeg' || $extension=='png' || $extension=='gif') {
$images[]=$filename;
if (!file_exists($thumb->Thumblocation.$thumb->Thumbprefix.$filename))
$newthumbs[]=$filename;
}
}
}
}
// Create and save new thumbs if required
if (count($newthumbs)>0) {
if (!file_exists($thumb->Thumblocation)) {@mkdir($thumb->Thumblocation);@chmod($thumb->Thumblocation,octdec($thumb->Chmodlevel));}
$thumb -> Createthumb($newthumbs);
}
// CSS style
echo "<style type=\"text/css\">\n";
echo "a:link,a:visited,a:hover {\n";
echo " font-family : Helvetica, Arial;\n";
echo " font-size : 12px;\n";
echo " color : #000000;\n";
echo " text-decoration : none;\n";
echo "}\n";
echo "</style>\n";
// The main table
echo "<table width=\"100%\" height=\"100%\"><tr><td align=\"center\" valign=\"middle\">\n";
// Display the thumbs or photo in an inner table
$column=0;
$table=explode('x',$tableformat);
$tablesize=$table[0]*$table[1];
if (isset($_REQUEST['page'])) {$page=intval($_REQUEST['page']);} else {$page=1;}
if (isset($_REQUEST['photo'])) {$photo=$_REQUEST['photo'];} else {$photo='';}
echo "<table>\n";
if ($photo=='') {
foreach($images as $key => $image) {
if ($key>=($tablesize*($page-1)) && $key<($tablesize*$page)) {
if ($column==0) {echo "<tr>";}
echo "<td><a href=\"$scriptname?page=$page&photo=" . urlencode($image) . "\"><img src=\"" . $thumb->Thumblocation.$thumb->Thumbprefix.$image. "\" border=\"0\"></a></td>";
$column+=1;
if ($column==$table[0]) {$column=0;echo "</tr>\n";}
}
}
if ($column<$table[0] && $column>0)
echo str_repeat('<td> </td>',$table[0]-$column) . "</tr>\n" . "</table>\n";
else
echo "</table>\n";
} else {
echo "<tr><td><a href=\"$scriptname?page=$page\"><img src=\"" . basename($photo) . "\" border=\"0\"></a></td></tr>\n". "</table>\n";
}
// Display the amount of pages in a seperate table
if ($tablesize<count($images) && $photo=='') {
echo "<table><tr><td align=\"center\">";
for ($i=1;$i<=ceil(count($images)/$tablesize);$i++) {
if ($page==$i) {echo " <a href=\"$scriptname?page=$i\"><u>$i</u></a>";} else {echo " <a href=\"$scriptname?page=$i\">$i</a>";}
}
echo "</td></tr></table>\n";
}
// Close the main table
echo "</td></tr></table>\n";