Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I "limit" the page numbers of a forum/blog in PHP
    text
    copied!<p>I'm trying to fix something with which I'm not familiar with and don't know how to proceed. The forum on which I'm working is suppose to show under "TOP 50" only the most commented topics (2 pages by 25 topics) but it shows all topics (by 25) without any limitation of the pages. I need only the first 2 pages - but don't know how to get rid of the others?</p> <p>I'm even not sure that the below code is the responsible one but please have a look and give me a hint if you see any solution. </p> <p>This is the code:</p> <pre><code> { public function __construct() { parent::__construct(); } public function get_forum() { if ($_GET['l'] &amp;&amp; ($_GET['l'] == 'leng' || $_GET['l'] == 'lrus' || $_GET['l'] == 'lde' || $_GET['l'] == 'ltr')) $l = substr($_GET['l'], 1); else $l = 'eng'; (isset($_GET['num'])) ? $page = intval($_GET['num']) : $page = 1; $id_user = intval($_SESSION['user_id']); $lang = language::getLang(); if ($_GET['el']) { switch ($_GET['el']) { case 'categories': return $this-&gt;getCategories($l); break; case 'top': $top_lang = $_GET['ln']; $c = $this-&gt;db-&gt;selectAssoc($this-&gt;db-&gt;Select('*', 'forum_categories ,forum_thems', "`forum_categories`.`lang` = '" . $l . "' AND `forum_thems`.`id_categories` = `forum_categories`.`id`")); $total_pages = count($c) / 25; $p = "&lt;div class=\"pageCounter_box\"&gt;Pages:"; if (empty($_GET['p'])) { $_GET['p'] = 1; } for($i=1; $i&lt;$total_pages+1; $i++){ if ($i == $_GET['p']) { $class = 'class="active_page"'; } $p .= "&lt;a href=\"$top_lang/smoke/{$_GET['l']}/top?p=$i\" $class&gt;$i&lt;/a&gt;"; } $p .= "&lt;/div&gt;"; return $this-&gt;getTop($l) . $p; break; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload