Forum Moderators: coopster
<?php
//connect to the database
$link = mysql_connect("localhost", "admin", "pass")
or die("Could not connect: " . msql_error());
mysql_select_db("gallery", $link)
or die (mysql_error());
$ImageDir = "/ballooncrew/gallery/centerpieces/";
$ImageThumb = $ImageDir . "/thumbs/";
$max_cols = 4;
?>
<html>
<head>
<title>Welcome to our Centerpeices Photo Gallery</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body bgcolor="#000000" text="#FFFFFF">
<p align="center">Click on any image to see it full sized.</p>
<table align="center">
<?php
// echo "<tr>";
// for ($i = 0; $i < $max_cols; $i+=1) {
// echo " <td align=\"center\">Image</td>";
// echo " <td align=\"center\">Caption</td>";
// echo " <td align=\"center\">Date Uploaded</td>";
//}
//echo "</tr>";
?>
<tr>
<?php
$counter = 0;
//get the thumbs
$getpic = mysql_query("SELECT * FROM gallery_centerpieces")
or die(mysql_error());
while ($rows = mysql_fetch_array($getpic)) {
extract($rows);
if ($counter % $max_cols == 0 && $counter!= 0) { echo "</tr><tr>\n"; }
echo "<td><a href=\"".$ImageDir . $image_id . ".jpg\">";
echo "<img src=\"" . $ImageThumb . $image_id . ".jpg\" border=\"0\">";
echo "</a></td>\n";
//echo "</tr>\n";
$counter += 1;
}
?>
</table>
</body>
</html>
use this in head:
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source! [javascript.internet.com...] -->
<!-- Begin
function CaricaFoto(img){
foto1= new Image();
foto1.src=(img);
Controlla(img);
}
function Controlla(img){
if((foto1.width!=0)&&(foto1.height!=0)){
viewFoto(img);
}
else{
funzione="Controlla('"+img+"')";
intervallo=setTimeout(funzione,20);
}
}
function viewFoto(img){
largh=foto1.width+20;
altez=foto1.height+20;
stringa="width="+largh+",height="+altez;
finestra=window.open(img,"",stringa);
}
// End -->
</script>
////////////////////////////////HEAD ENDS////
Call each image by using this example....
<A HREF="javascript:CaricaFoto('photos/<? echo $photo2?>')" alt="<? echo $desc2?>" BORDER="0">
<img src="photos/thumbs/<? echo $thumb2?>" alt="<? echo $desc2?>" width="150" height="113">
...................................................
hope it works 4 u, i know it is good cause I use it ...
echo "<td><a href=\"".$ImageDir . $image_id . ".jpg\">";
echo "<img src=\"" . $ImageThumb . $image_id . ".jpg\" border=\"0\">";
echo "</a></td>\n";
to:
echo "<td><a href=\"http:www.host.com/".$ImageDir.$image_id.".jpg\" target=\"_blank\">";
echo "<img src=\"".$ImageThumb.$image_id."jpg\" border=\"0\" alt=\"image\" title=\"view image full screen\">";
echo "</a></td>\n";
should do the trick, no need for fancy javascript if HTML can do it :)
seems to me you arent quite into the html tags, as you neglected the ALT and TITLE attributes for the <img> tag. The ALT attribute is required, the title attribute a very handy optional attribute
the 'target' attribute for the <a> tag is very handy also and you also left it out
if you set it to "_SELF" it will open the image in the current window, if you set it to "_BLANK" it will open in a new window