here is my code please help me to make a paginal output

<?php include("db_connection.php"); if(isset($_GET['cat_id'])){ $sqlQuery = " SELECT * FROM `news` WHERE `id_category` = ".$_GET['cat_id']."; "; }else{ $sqlQuery = " SELECT * FROM `news`; "; } $sql = mysql_query($sqlQuery) or die(mysql_error()); $rows = array(); while($r = mysql_fetch_array($sql, MYSQL_ASSOC)){ $rows[] = $r; } foreach($rows as $row){ ?> <h1><?php echo $row['title']; ?></h1> <p><?php echo $row['small_text']; ?></p> <h3>Автор: <?php echo $row['author']; ?> </h3> <h6>Дата: <?php echo $row['data']; ?></h6> <a href="/news.php?id=<?php echo $row['id']; ?>">Читать Дальше</a> <hr/> <?php }?> 

    1 answer 1

    You do not have the correct implementation, or you did not finish. The script must accept a getter parameter that indicates which page the user is on. For example, $_GET['page']; There should also be a variable indicating how many elements are on the page.

     $pageCount = 10; 

    We calculate which record to start sampling for the query:

     $start = $pageCount * $_GET['page']; 

    The request condition should look like this:

    SELECT ... WHERE ... ORDER BY category_id LIMIT $ start, $ pageCount