AN-net
02-18-2004, 10:34 PM
im trying to use vb's pagination but it isnt working
i keep getting division of by zero on line 1611 in includes/functions.php.
this is the code:
$limit=2;
$query_count= $DB_site->query("SELECT * FROM gallery WHERE gallery_id='$id'");
$totalrows= $DB_site->num_rows($query_count);
if(empty($page)){
$page=1;
}
sanitize_pageresults($totalrows, $page, $limit,100);
$limitlower = ($page - 1) * $limit+1;
$limitupper = ($page) * $limit;
if ($limitupper > $totalrows)
{
$limitupper = $totalrows;
if ($limitlower > $totalrows)
{
$limitlower = $totalrows-$limit;
}
}
if ($limitlower <= 0)
{
$limitlower = 1;
}
$fgall= $DB_site->query("SELECT gallery_index.gallery_views,gallery.* FROM gallery,gallery_index WHERE gallery_index.gallery_id='$id' AND gallery.gallery_id='$id' LIMIT " . ($limitlower-1) . ",$limit $type $order");
$imagesnum=$DB_site->num_rows($fgall);
if($imagesnum==0){
$DB_site->query("UPDATE gallery_index SET gallery_views=gallery_views+1 WHERE gallery_id='$id'");
$fgalnav=$DB_site->query("SELECT gallery_index.gallery_name FROM gallery_index WHERE gallery_index.gallery_id='$id'");
$galnav=$DB_site->fetch_array($fgalnav);
$navbits = array();
$navbits["#"] = "Gallery";
$navbits["gallery.php?view=index"] = "Gallery Index";
$navbits[''] = $galnav[gallery_name];
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
mysql_free_result($fgalnav);
eval('print_output("' . fetch_template('gallery_gal_none') . '");');
}
else{
while($gallery= $DB_site->fetch_array($fgall))
{
if($gallery[image_totalvotes]==0){
$rating=0;
}
else{
$calcrating= $gallery[image_totalrating]/$gallery[image_totalvotes];
$rating= round($calcrating);
}
$galleryimagedate=date("m/d/Y - g:i A",$gallery[image_date]);
if($galoption[gallerybit]==1){
eval('$gallerybits .= "' . fetch_template('gallery_gal_lvl1alt') . '";');
}
else{
eval('$gallerybits .= "' . fetch_template('gallery_gal_lvl1') . '";');
}
}
mysql_free_result($fgall);
$DB_site->query("UPDATE gallery_index SET gallery_views=gallery_views+1 WHERE gallery_id='$id'");
$fgalnav=$DB_site->query("SELECT gallery_index.gallery_name FROM gallery_index WHERE gallery_index.gallery_id='$id'");
$galnav=$DB_site->fetch_array($fgalnav);
$navbits = array();
$navbits["#"] = "Gallery";
$navbits["gallery.php?view=index"] = "Gallery Index";
$navbits[''] = $galnav[gallery_name];
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
$pagenav = construct_page_nav($totalrows, "gallery.php?view=gal&id=$id", "&pp=$limit");
mysql_free_result($fgalnav);
if(in_array($bbuserinfo['usergroupid'], array(4,5,6)))
{
eval('$submitgal .= "' . fetch_template('gallery_subbutton') . '";');
}
eval('print_output("' . fetch_template('gallery_gal') . '");');
can anyone help?
it show the lil page nav page with "Page of 0"
i keep getting division of by zero on line 1611 in includes/functions.php.
this is the code:
$limit=2;
$query_count= $DB_site->query("SELECT * FROM gallery WHERE gallery_id='$id'");
$totalrows= $DB_site->num_rows($query_count);
if(empty($page)){
$page=1;
}
sanitize_pageresults($totalrows, $page, $limit,100);
$limitlower = ($page - 1) * $limit+1;
$limitupper = ($page) * $limit;
if ($limitupper > $totalrows)
{
$limitupper = $totalrows;
if ($limitlower > $totalrows)
{
$limitlower = $totalrows-$limit;
}
}
if ($limitlower <= 0)
{
$limitlower = 1;
}
$fgall= $DB_site->query("SELECT gallery_index.gallery_views,gallery.* FROM gallery,gallery_index WHERE gallery_index.gallery_id='$id' AND gallery.gallery_id='$id' LIMIT " . ($limitlower-1) . ",$limit $type $order");
$imagesnum=$DB_site->num_rows($fgall);
if($imagesnum==0){
$DB_site->query("UPDATE gallery_index SET gallery_views=gallery_views+1 WHERE gallery_id='$id'");
$fgalnav=$DB_site->query("SELECT gallery_index.gallery_name FROM gallery_index WHERE gallery_index.gallery_id='$id'");
$galnav=$DB_site->fetch_array($fgalnav);
$navbits = array();
$navbits["#"] = "Gallery";
$navbits["gallery.php?view=index"] = "Gallery Index";
$navbits[''] = $galnav[gallery_name];
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
mysql_free_result($fgalnav);
eval('print_output("' . fetch_template('gallery_gal_none') . '");');
}
else{
while($gallery= $DB_site->fetch_array($fgall))
{
if($gallery[image_totalvotes]==0){
$rating=0;
}
else{
$calcrating= $gallery[image_totalrating]/$gallery[image_totalvotes];
$rating= round($calcrating);
}
$galleryimagedate=date("m/d/Y - g:i A",$gallery[image_date]);
if($galoption[gallerybit]==1){
eval('$gallerybits .= "' . fetch_template('gallery_gal_lvl1alt') . '";');
}
else{
eval('$gallerybits .= "' . fetch_template('gallery_gal_lvl1') . '";');
}
}
mysql_free_result($fgall);
$DB_site->query("UPDATE gallery_index SET gallery_views=gallery_views+1 WHERE gallery_id='$id'");
$fgalnav=$DB_site->query("SELECT gallery_index.gallery_name FROM gallery_index WHERE gallery_index.gallery_id='$id'");
$galnav=$DB_site->fetch_array($fgalnav);
$navbits = array();
$navbits["#"] = "Gallery";
$navbits["gallery.php?view=index"] = "Gallery Index";
$navbits[''] = $galnav[gallery_name];
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
$pagenav = construct_page_nav($totalrows, "gallery.php?view=gal&id=$id", "&pp=$limit");
mysql_free_result($fgalnav);
if(in_array($bbuserinfo['usergroupid'], array(4,5,6)))
{
eval('$submitgal .= "' . fetch_template('gallery_subbutton') . '";');
}
eval('print_output("' . fetch_template('gallery_gal') . '");');
can anyone help?
it show the lil page nav page with "Page of 0"