Thanks bogu. I'm still a bit stuck though. I'm trying to use it like a photo gallery but it's still not working. Heres my code so far:
<?php require_once('../Connections/aap_connect.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];
$colname_photoRS = "-1";
if (isset($_GET['picURL1'])) {
$colname_photoRS = (get_magic_quotes_gpc()) ? $_GET['picURL1'] : addslashes($_GET['picURL1']);
}
mysql_select_db($database_aap_connect, $aap_connect);
$query_photoRS = sprintf("SELECT * FROM tbl_gallery WHERE picURL1 = '%s'", $colname_photoRS);
$photoRS = mysql_query($query_photoRS, $aap_connect) or die(mysql_error());
$row_photoRS = mysql_fetch_assoc($photoRS);
$totalRows_photoRS = mysql_num_rows($photoRS);
$queryString_photoRS = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_photoRS") == false &&
stristr($param, "totalRows_photoRS") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_photoRS = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_photoRS = sprintf("&totalRows_photoRS=%d%s", $totalRows_photoRS, $queryString_photoRS);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="JavaScript"><!--
which_image_loaded = 0;
NUMBER_OF_IMAGES = 20;
ImageNames = new Array;
ImageNames.length = NUMBER_OF_IMAGES - 1;
<?php
for ( $counter=0; $counter < NUMBER_OF_IMAGES; ++$counter) {
echo "filename = (\"../gallery/manado/{$row_photoRS['picURL' + $counter]}\");";
echo "ImageNames[{$counter}] = filename;";
}
?>
function changeImage(direction) {
which_image_loaded += direction;
if (which_image_loaded < 0)
which_image_loaded = NUMBER_OF_IMAGES - 1;
if (which_image_loaded == NUMBER_OF_IMAGES)
which_image_loaded = 0;
document.myimage.src = ImageNames[which_image_loaded];
}
//--></script>
</head>
<body>
<table width="50" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><img src="../gallery/<?php echo $row_photoRS['picURL1']; ?>" alt="" name="myimage" id="myimage" /></td>
</tr>
</table>
<p align="center">
<a href="#"></a></p>
<form>
<div align="center">
<input name="button" type="button" onclick='changeImage(-1);' value="<<" />
<input name="button2" type="button" onclick='changeImage(1);' value=">>" />
</div>
</form>
<p align="center"> </p>
</p>
</body>
</html>
<?php
mysql_free_result($photoRS);
?>
Could you please tell me where I'm going wrong?