Hello everyone! I’ve been trying to add pagination to my forum for some days but without any success… So can someone help me? The database table is called topics and here’s my list_topics.php :
[php]<?php
//This page let display the list of topics of a category
include(‘config.php’);
if(isset($_GET[‘parent’]) and ($_GET[“page”])) { $page = $_GET[“page”]; } else { $page=1; };
{
$start_from = ($page-1) * 20;
$id = intval($_GET[‘parent’]);
$dn1 = mysql_fetch_array(mysql_query(‘select count(c.id) as nb1, c.name,count(t.id) as topics from categories as c left join topics as t on t.parent="’.$id.’" where c.id="’.$id.’" group by c.id’));
if($dn1[‘nb1’]>0)
{
?>
Topic | Author | Replies | <?php if(isset($_SESSION['username']) and $_SESSION['username']==$admin) { ?>Action | <?php } ?>
---|---|---|---|
<?php echo htmlentities($dnn2['title'], ENT_QUOTES, 'UTF-8'); ?> | <?php echo htmlentities($dnn2['author'], ENT_QUOTES, 'UTF-8'); ?> | <?php echo $dnn2['replies']; ?> | <?php if(isset($_SESSION['username']) and $_SESSION['username']==$admin) { ?>
You need to be logged in to browse the forum!
This category doesn\'t exist.
'; } } ?>[/php]So basically it shows only 20 topics but I couldn’t managed to add the pages and i also get this error:
Notice: Undefined index: page in C:\xampp\htdocs\Forum\list_topics.php on line 4