ok I’ve got this database table named data containing six rows!
what i want paginate the data & display only two columns from the table! I’m giving my code, it displays the table Header row only with no data inside.
If you are on the first page then you are selecting zero results. Without $_GET[‘page’], you set $page to equal 1, then in your $start_from variable you are deducting 1 from the number stored in the $page variable and then multiplying by 5. so, on your first page $page = 1, you then deduct 1 which will give you $page = 0 and then multiply by 5 which will give you $start_from = 0 (5 * 0 = 0).
is this one alright?
if (isset($_GET[“page”])) { $page = $_GET[“page”]; } else { $page=1; };
$start_from = ($page);
$sql = “SELECT * FROM data ORDER BY roll ASC LIMIT $start_from, 1”;
$rs_result = mysql_query ($sql,$connection);
I don’t think so based on what you were trying to do. If you want 5 records per page:
if (isset($_GET["page"])) { $page = $_GET["page"];
$start_from = ($page * 5) - 4;
}else {
$start_from=0;
}
$sql = "SELECT * FROM data ORDER BY roll ASC LIMIT $start_from, 5";
No, not the right number of rows, the table sizes increases just a little, as if just showing 1 data only!! Do u have any or know any links for any php pagination tutorial please?