aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2018-11-01 12:07:35 +0100
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2018-11-01 12:08:51 +0100
commitfd215fa69ad79ea8b915850dc804248884bc3a09 (patch)
treea7e83c3bda2f0a4ed8810606101195d8c65c3c03 /web
parent13ce40e354eaaf62a05b4cdddf4d9a37b0e3ed61 (diff)
downloadbuildroot-test-fd215fa69ad79ea8b915850dc804248884bc3a09.tar.gz
buildroot-test-fd215fa69ad79ea8b915850dc804248884bc3a09.tar.bz2
web: show proper result count and currently displayed count
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Diffstat (limited to 'web')
-rw-r--r--web/funcs.inc.php5
-rw-r--r--web/index.php11
2 files changed, 11 insertions, 5 deletions
diff --git a/web/funcs.inc.php b/web/funcs.inc.php
index 14256bb..7e912c1 100644
--- a/web/funcs.inc.php
+++ b/web/funcs.inc.php
@@ -60,10 +60,11 @@ function bab_format_sql_filter($db, $filters)
/*
* Returns the total number of results.
*/
-function bab_total_results_count()
+function bab_total_results_count($filters)
{
$db = new db();
- $sql = "select count(*) from results;";
+ $condition = bab_format_sql_filter($db, $filters);
+ $sql = "select count(*) from results $condition;";
$ret = $db->query($sql);
if ($ret == FALSE) {
echo "Something's wrong in here\n";
diff --git a/web/index.php b/web/index.php
index 890de8a..f3af62d 100644
--- a/web/index.php
+++ b/web/index.php
@@ -156,7 +156,7 @@ echo "</table>\n";
echo "<p style=\"text-align: center;\">";
-$total = bab_total_results_count();
+$total = bab_total_results_count($filters);
$prev_args = $filters;
$next_args = $filters;
@@ -168,10 +168,15 @@ $next_args["start"] = $start + $step;
if ($start != 0)
echo "<a href=\"?" . format_url_args($prev_args) . "\">Previous results</a>&nbsp;-&nbsp;";
-echo "(" . $start . " - " . ($start + $step) . " / " . $total . " results)&nbsp;-&nbsp;";
+if ($start + $step > $total)
+ $end = $total;
+else
+ $end = $start + $step;
+
+echo "(" . $start . " - " . $end . " / " . $total . " results)";
if (($start + $step) < $total)
- echo "<a href=\"?" . format_url_args($next_args) . "\">Next results</a>";
+ echo "&nbsp;-&nbsp;<a href=\"?" . format_url_args($next_args) . "\">Next results</a>";
echo "</p>";