hi folks,
i am trying to create next and previous button along with the links of the page numbers....
although the page number links are working fine but the next and the previous button are not working as required..
Help me out with this..
The code is..
<?php
// database connection stuff here
$db = mysql_connect("localhost", "vivek", "tarun150"
or die ("Could not connect"
//print ("Connected successfully"
mysql_select_db ("vivek"
or die ("Could not select database"
$rows_per_page = 30;
$sql = "SELECT * FROM pat where cc='au'";
$result = mysql_query($sql, $db);
$total_records = mysql_num_rows($result);
$pages = ceil($total_records / $rows_per_page);
mysql_free_result($result);
print "$pages";
if (!isset($screen))
$screen = 0;
$start = $screen * $rows_per_page;
$sql = "SELECT tl FROM pat where cc='au' ";
$sql .= "LIMIT $start, $rows_per_page";
$result = mysql_query($sql, $db);
$rows = mysql_num_rows($result);
for ($i = 0; $i < $rows; $i++) {
$description = mysql_result($result, $i, 0);
echo "\$description = $description<br>\n";
}
echo "<p><hr></p>\n";
// let's create the dynamic links now
*********************************this does'nt work**********
if ($screen > 0) {
$url = "example.php?screen=" . $screen - 1;
echo "<a href=\"$url\">Previous</a>\n";
}
*********************************this does'nt work**********
// page numbering links now
for ($i = 0; $i < $pages; $i++) {
$url = "example.php?screen=" . $i;
echo " | <a href=\"$url\">$i</a> | ";
}
*********************************this does'nt work**********
if ($screen < $pages) {
$url = "example.php?screen=" . $screen + 1;
echo "<a href=\"$url\">Next</a>\n";
}
*********************************this does'nt work**********
?>
i am trying to create next and previous button along with the links of the page numbers....
although the page number links are working fine but the next and the previous button are not working as required..
Help me out with this..
The code is..
<?php
// database connection stuff here
$db = mysql_connect("localhost", "vivek", "tarun150"
or die ("Could not connect"
//print ("Connected successfully"
mysql_select_db ("vivek"
or die ("Could not select database"
$rows_per_page = 30;
$sql = "SELECT * FROM pat where cc='au'";
$result = mysql_query($sql, $db);
$total_records = mysql_num_rows($result);
$pages = ceil($total_records / $rows_per_page);
mysql_free_result($result);
print "$pages";
if (!isset($screen))
$screen = 0;
$start = $screen * $rows_per_page;
$sql = "SELECT tl FROM pat where cc='au' ";
$sql .= "LIMIT $start, $rows_per_page";
$result = mysql_query($sql, $db);
$rows = mysql_num_rows($result);
for ($i = 0; $i < $rows; $i++) {
$description = mysql_result($result, $i, 0);
echo "\$description = $description<br>\n";
}
echo "<p><hr></p>\n";
// let's create the dynamic links now
*********************************this does'nt work**********
if ($screen > 0) {
$url = "example.php?screen=" . $screen - 1;
echo "<a href=\"$url\">Previous</a>\n";
}
*********************************this does'nt work**********
// page numbering links now
for ($i = 0; $i < $pages; $i++) {
$url = "example.php?screen=" . $i;
echo " | <a href=\"$url\">$i</a> | ";
}
*********************************this does'nt work**********
if ($screen < $pages) {
$url = "example.php?screen=" . $screen + 1;
echo "<a href=\"$url\">Next</a>\n";
}
*********************************this does'nt work**********
?>