Hi,
I am new to php and am trying to write an image gallery script. It is database driven through MySQL. I have a page which generates thumbnails from info held on the database. The thumbnails are links which pass the image id to a script which displays the full size image with info. My problem is that it seems to be very hit and miss whether the image displays or I get a blank screen.
Here is the script:
<?php
mysql_select_db($database_Images, $Images);
$query_Recordset1 = "SELECT * FROM image_list where image_type='CA'";
$Recordset1 = mysql_query($query_Recordset1, $Images) or die(mysql_error());
$result = mysql_query ($query_Recordset1, $Images);
$rowcount = mysql_num_rows($result);
$count =0;
echo "<div id=\"box1\"><table cellpadding=0 cellspacing = 10 border=0 align=\"center\">";
echo "<tr>\n";
while ($newArray = mysql_fetch_array($Recordset1)) {
$id = $newArray ['id'];
$name = $newArray ['item_name'];
$desc = $newArray ['item_desc'];
$price = $newArray ['item_price'];
$url = $newArray ['url'];
$count ++;
echo "<td width = \"100\" align = \"center\" valign=\"bottom\">";
echo "<a href = \"http://cgi.coles3.plus.com/showimage.php?id=$id\" target=\"_self\"><img src=thumb//$name border=3></a><br>";
echo "<div align=\"left\">";
echo "CA"; printf ("%04d", $id);
echo "</td>\n";
And here is the showimage.php script
<?php
// Do your code to connect to mySQL db etc.
require_once('Connections/coles3_pn.php');
// Then do this
if (isset($_GET['id'])) {
$id = ($_GET['id']);
$sql = "SELECT * FROM image_list WHERE id=$id";
if ($result = mysql_query ($sql)) {
$row = mysql_fetch_array ($result);
$fullpath = $row['item_name'];
$price = $row['item_price'];
$desc = $row['item_desc'];
$size = $row['size'];
$type = $row['Image_type'];
$url="Ceramics.php";
if ($type == "DI") {
($url = "Digital.php");
}
else {
($url = "Ceramics.php");
}
//echo $fullpath;
echo "<div id=\"box1\" align=\"center\">";
echo "<table width=\"600\" cellpadding=\"20\" border=\"0\" bgcolor=\"#bad3f3\" align=\"center\">
<tr><td rowspan=\"2\" width=\"400\">\n<a href = \"$url\">
<img src=\"Thumb1/$fullpath\" alt=\"click on image to return to Gallery\" border=2></a><br>\n";
echo "<td valign=\"bottom\">($desc)</td></tr>
<tr><td valign=\"bottom\">£$price.00<br>($size)</td></tr>
</table>\n</div>";
}
}
?>