Hi, I am new at PHP. I need to make a pagination on my site and here's a code that seems to be working but when I go into different pages I get a message that says "page not found". Can someone please help me with this. Thanks.
PHP Code:<?php
$username="pass";
$password="pass";
$database="mysql";
$dbh=mysql_connect(localhost,$username,$password) or die ('I cannot connect to the database because: ' . mysql_error());
@mysql_select_db($database);
$result = mysql_query("SELECT COUNT(*) AS total_entries FROM help_topic") or die(mysql_error());
$row = mysql_fetch_row($result);
$total_entries = $row[0];
$entries_per_page = 25;
if(isset($_GET['currentpage'])) {
$page_number = $_GET['currentpage'];
} else {
$page_number = 1;
}
$total_pages = ceil($total_entries / $entries_per_page);
$offset = ($page_number - 1) * $entries_per_page;
$result = mysql_query("SELECT * FROM help_topic LIMIT $offset, $entries_per_page") or die(mysql_error());
while($obj = mysql_fetch_array($result)) {
// Display the data however you want here.
print $obj ['url'];
echo "<br>";
}
for($i = 1; $i <= $total_pages; $i++) {
if($i == $page_number) {
// This is the current page. Don't make it a link.
print "$i ";
}else {
// This is not the current page. Make it a link.
print "<a href=\"untitled.php?page_number=$i\">$i</a> ";
}
}
?>
I really appreciate your help...






Bookmarks