hello, am trying to create some dynamic pages with php. Here are my codes:
<?php
// database connection stuff here
include("dbinfo.inc.php");
$rows_per_page = 2;
$sql = "SELECT * FROM images";
$result = mysql_query($sql, $db);
$total_records = mysql_num_rows($result);
$pages = ceil($total_records / $rows_per_page);
mysql_free_result($result);
if (!isset($screen))
$screen = 0;
$start = $screen * $rows_per_page;
$sql = "SELECT Description FROM images ";
$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
if ($screen > 0) {
$url = "example.php?screen=" . $screen - 1;
echo "<a href=\"$url\">Previous</a>\n";
}
// page numbering links now
for ($i = 0; $i < $pages; $i++) {
$url = "example.php?screen=" . $i;
echo " | <a href=\"$url\">$i</a> | ";
}
if ($screen < $pages) {
$url = "example.php?screen=" . $screen + 1;
echo "<a href=\"$url\">Next</a>\n";
}
?>
But it is not working. The DB connection is ok, but the links are not working.
Can some1 try to tell me my error ?
Thanks
Regards
mungra