Ok, I’ll paste my code here, it goes like if a person selects a category and then he lands to another page, now here the problem is because mysql_fetch_rows selects all the rows of all categories, so if there are 10 entries, 5 in each category and if i set to show 1 post per each page instead of showing 5 pages it shows 10 pages but after page 5 i get a php error. thank you n here’s my code
$pagination_shoot = "SELECT id, po_title, po_category FROM tbl_posts WHERE po_category = '{$category}'";
$page_dump = mysql_query($pagination_shoot, $db_connect);
$no_rows = mysql_fetch_row($page_dump);
$numrows = $no_rows[0];
$rows_per_page = 1;
$lastpage = ceil($numrows/$rows_per_page);
$page = (int)$page;
if ($page > $lastpage) {
$page = $lastpage;
} // if
if ($page < 1) {
$page = 1;
} // if
$limit = 'LIMIT ' .($page - 1) * $rows_per_page .',' .$rows_per_page;
//Run Post Query
$data_posts = "SELECT id, po_title, po_category FROM tbl_posts WHERE po_category = '{$category}' {$limit}"; //Post Query
$fetch_data_posts = mysql_query($data_posts, $db_connect);
while ($list_posts = mysql_fetch_array($fetch_data_posts))
Reading between the lines, I think what you are trying to do is fetch the results for a specific page from that database while knowing how many results there are in total, so you can work out how many pages there will be. Here is the right way to do that using
SQL_CALC_FOUND_ROWS: