From cc5ba30bd061d00be17bb26061962016e4112b9d Mon Sep 17 00:00:00 2001 From: plegall Date: Sat, 15 Jan 2005 11:16:46 +0000 Subject: [PATCH] - bug fixed : count the exact number of elements that can be displayed in most_visited category because it can be less than $conf['top_number'] git-svn-id: http://piwigo.org/svn/trunk@694 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_category.inc.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index 67be45b0e..2e7ce2903 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -592,7 +592,26 @@ SELECT COUNT(DISTINCT(id)) AS nb_total_images } $conf['order_by'] = ' ORDER BY hit DESC, file ASC'; - $page['cat_nb_images'] = $conf['top_number']; + + // $page['cat_nb_images'] equals $conf['top_number'] unless there + // are less visited items + $query =' +SELECT COUNT(DISTINCT(id)) AS count + FROM '.IMAGES_TABLE.' + INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id + '.$page['where'].' +;'; + $row = mysql_fetch_array(pwg_query($query)); + if ($row['count'] < $conf['top_number']) + { + $page['cat_nb_images'] = $row['count']; + } + else + { + $page['cat_nb_images'] = $conf['top_number']; + } + unset($query); + if ( isset( $page['start'] ) and ($page['start']+$user['nb_image_page']>=$conf['top_number'])) {