PDA

View Full Version : PHP Photo Album script - Fails



wmguk
08-20-2008, 01:15 PM
1) Script Title: PHP Photo Album script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm

3) Describe problem:

I have edited the script and I now get "galleryarray is undefined".

this is the code on my page.



<?php
$login = $_GET['login'];
$dir ="http://www.iwphoto.co.uk/clients/$login/";
include "../scripts/connection.php";
$result = mysql_query("SELECT * FROM album WHERE login = '$login'");
while($row = mysql_fetch_array($result))
{
$albumname = $row['albumname'];
$date_day = $row['date_day'];
$date_month = $row['date_month'];
$date_year = $row['date_year'];
$venue = $row['venue'];
$image_no = $row['image_no'];
$date = date("jS F Y", mktime(0, 0, 0, $date_month, $date_day, $date_year));
$picture = $row['picture'];
$active = $row['active'];
$counters = $row['counters'];
$pricing = $row['pricing'];
$ceremony = $row['ceremony'];
$password = $row['password'];
$user = $row['creator'];
}
?>
<!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=utf-8" />
<title>Untitled Document</title>
<link href="../styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
background-color: #ffffff;
}
-->
</style></head>
<body>
<script src="<? echo $dir; ?>getpics.php" type="text/javascript"></script>
<script type="text/javascript">

/***********************************************
* PHP Photo Album script- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

var dimension="20x1" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
var imagepath="<?php echo $dir ; ?>/" //Absolute path to image directory. Include trailing slash (/)
var href_target="order" //Enter target attribute of links, if applicable

//Toggle popup link setting: popupsetting[0 or 1, "pop up window attributes" (if 1)]
var popupsetting=[0, "width=500px, height=400px, scrollbars, resizable"]

//Toggle image description: descriptionprefix[0 or 1, "Text to show" (if 1)]
var descriptionprefix=[0, ""]

//Sort images by date? ("asc", "desc", or "")
//"desc" for example causes the newest images to show up first in the gallery
//"" disables this feature, so images are sorted by file name (default)
var gsortorder=""

//By default, each image hyperlinks to itself.
//However, if you wish them to link to larger versions of themselves
//Specify the directory in which the larger images are located
//The file names of these large images should mirror those of the original
//Enter a blank string ("") to disable this option
var targetlinkdir=""

/////No need to edit beyond here///////////////////

function sortbydate(a, b){ //Sort images function
if (gsortorder=="asc") //sort by file date: older to newer
return new Date(a[1])-new Date(b[1])
else if (gsortorder=="desc") //sort by file date: newer to older
return new Date(b[1])-new Date(a[1])
}

if (gsortorder=="asc" || gsortorder=="desc")
galleryarray.sort(sortbydate)

else
galleryarray.sort();

var totalslots=dimension.split("x")[0]*dimension.split("x")[1]

function buildimage(i){
var imagecompletepath=(targetlinkdir!="")? targetlinkdir+galleryarray[i][0] : imagepath+galleryarray[i][0]
var name=galleryarray[i][0]
var tempcontainer='<a href="dis.php?name='+name+'&amp;image=<? echo $login; ?>/'+name+'&amp;login=<? echo $login; ?>&amp;ceremony=<? echo $ceremony; ?>&amp;pricing=<? echo $pricing; ?>&amp;user=<? echo $user; ?>&amp;counters=<? echo $counters; ?>" target="'+href_target+'" onClick="return popuplinkfunc(this)">'
tempcontainer+='<img width="120px" border="0" vspace="1" src="'+imagepath+galleryarray[i][0]+'" title="'+galleryarray[i][0]+' ['+galleryarray[i][1]+']" />'
tempcontainer+='</a><br />'
tempcontainer+=(descriptionprefix[0]==1)? descriptionprefix[1]+(i+1) : ""
return tempcontainer
}

function jumptopage(p){
var startpoint=(p-1)*totalslots
var y=1;
for (i=0; i<totalslots; i++){
document.getElementById("slide"+i).innerHTML=(typeof galleryarray[startpoint+i]!="undefined")? buildimage(startpoint+i) : ""
}
while(document.getElementById("navlink"+y)!=null){
document.getElementById("navlink"+y).className=""
y++
}
document.getElementById("navlink"+p).className="current"
}

var curimage=0
for (y=0; y<dimension.split("x")[1]; y++){
for (x=0; x<dimension.split("x")[0]; x++){
if (curimage<galleryarray.length)
document.write('<div id="slide'+curimage+'" class="slideshow">'+buildimage(curimage)+'</div>')
curimage++
}
document.write('<br style="clear: left" />')
}

function popuplinkfunc(imgsrc){
if (popupsetting[0]==1){
var popwin=open(imgsrc.href, "popwin", popupsetting[1])
popwin.focus()
return false
}
else
return true
}

</script>

<!--Below HTML code refers to the navigational links for the gallery-->

<div class="main" >
<script type="text/javascript">
for (i=1; i<Math.ceil(galleryarray.length/totalslots)+1; i++)
document.write('<a id="main'+i+'" href="javascript:jumptopage('+i+')\">Page'+i+'</a> ')
document.getElementById("navlink1").className="current"
</script>
</div>
</body>
</html>


any thoughts?