Hi guys,
I'm trying to get next and previous links for my album pages. The album pages are using my modified show_highest_rating function (which I posted here a while back)
Anyway here is the code I'm trying to get to work:
`if(isset($_SESSION['album_start'])) {
$offset=intval($_SESSION['album_start']);
print "nn";
}
else {
$offset=0;
print "nn";
}
$perpage=25; // images per page
show_highest_rated($offset,$perpage);
// Show images thumbnails from $st for $pp
function show_highest_rated($offset,$perpage) {
$images=load_highest_rated();
$size = '_'.zp_conf('thumb_size').'_cw'.zp_conf('thumb_crop_width').'_ch'.zp_conf('thumb_crop_height');
$max=count($images);`
`for($i=$offset;$i<$offset+$perpage && $i<count($images);$i++) {<br />
print "n";
$image=$images[$i];
$filename = $image['filename'];
$album = $image['folder'];
$desc = $image['imgtitle'];
$totalvalue =
@number_format($image['totalvalue']/$image['votes'],2);
echo '
';
}
// Here: print navigators
$offset=$_SERVER['PHP_SELF'];
$album=strtolower(getAlbumTitle());
if($offset>0) {
$prev=max($offset-$perpage,0);
print "
<< prev</a> ";
}
if($offset+$perpage
$next=min($offset+$perpage,count($images)-1);
print "next >> ";
}
}
// Load image list for current selected album
function load_highest_rated() {
$album=getAlbumTitle();
$pagname="pag_".$album;
$aryImages=array();
// This album is in the session
if(isset($_SESSION[$pagname])) {
//print "nn";
$aryImages=$_SESSION[$pagname];
}
else {
// Album not in session: load it from db
$aryImages = query_full_array("SELECT images.albumid, images.filename AS filename, images.title AS imgtitle, ratings.total_value AS totalvalue, ratings.total_votes as votes, albums.folder AS folder, albums.title FROM images AS images JOIN albums AS albums JOIN ratings ON albums.id = images.albumid ON images.id = ratings.id WHERE albums.title = '".getAlbumTitle()."' ORDER BY (ratings.total_value/ratings.total_votes) DESC");
$_SESSION[$pagname]=$aryImages;
//print "nn";
}
return $aryImages;`
And I've added this to index.php in the main folder:
`session_start();
if(isset($_GET['offset'])) {
$_SESSION['album_start']=$_GET['offset'];
die("debug: start param found");
}
else {
unset($_SESSION['album_start']);
}`
As far as I can tell the reason it isn't working is because of mod_rewrite (though I'm probably wrong so hopefully you can tell me what's wrong) I've tried adding this to .htaccess:
`RewriteRule ^([^/]+)/offset/([0-9]+)/$ index.php?album=$1&offset=$2 [L,QSA]`
But it doesn't work.
You can see it in action here
http://www.dualmonitorbackgrounds.com/abstract/When you click "next >>" it just goes back to the page instead of the offset page.
Please help