Sorry, the above script works fine.
Here is the one that don't work:
PHP Code:
// initialization
$pid = (int)($_GET['pid']);
// Finds the previous and next image in the array
$result3 = mysql_query( "SELECT photo_id, sectorid, photo_filename FROM photos
WHERE sectorid=2
ORDER BY date" );
$num_rows = mysql_num_rows( $result3 );
$j=0;
while ($num_rows > $j) {
$prev=mysql_result($result3,$j,"photo_id");
$j++;
$myarray = array("$j"=>"$prev");
foreach($myarray as $key=>$value2) {
if ($value2 == "$pid"){
$b=($key);
$a=($key-1);
$c=($key+1);
}}
}
if($a == "0") {
echo "<span class='nextimg'>No photos found</span>";
} else {
if($key == "$value2")
echo "<span class='nextimg'><a href=index.php?sid=2&pid=$a><img src='../images/arrow_left.gif' border='0' /></a></span>";
}
$i=0;
while ($i < $num_rows) {
$next=mysql_result($result3,$i,"photo_id");
$i++;
$myarray = array("$i"=>"$next");
foreach($myarray as $key=>$value) {
if ($value == "$pid"){
$b=($key);
$a=($key-1);
$c=($key+1);
}}
if ($num_rows < $value) {
echo "<span class='previmg'>No photos found</span>";
} else {
if ($key == "$c") echo "<span class='previmg'><a href=index.php?sid=2&pid=$value><img src='../images/arrow_right.gif' border='0' /></a></span>";
}
}
The script is supposed to navigate to the next row in the array. It adds to the $pid variable with +/÷1. "mysite.no/folder/index.php?sid=1&pid=12".
It should move to pid=11/pid=13 next - showing the prevoius/next image in the array.
R
Bookmarks