if ($type != "") {
if (!isset($_GET['page'])) {
$page = 1;
} else {
$page = $_GET['page'];
}
$max_results = 25;
$from = (($page * $max_results) - $max_results);
$Link = mysql_connect($host, $username, $password) or die (mysql_error());
mysql_select_db('files');
$Query = "SELECT * FROM file_data WHERE type = '$type' order by ID DESC LIMIT $from, $max_results";
$result = mysql_query($Query, $Link) or die ( mysql_error());
while($row = mysql_fetch_array($result)) {
print("<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"98%\" id=\"AutoNumber1\">\n");
print("<tr>\n");
print("<td width=\"36%\" align=\"center\">File Title</td>\n");
print("<td width=\"35%\" align=\"center\">Author</td>\n");
print("<td width=\"29%\" align=\"center\">Download times</td>\n");
print("</tr>\n");
while ($Row = mysql_fetch_array ($result)) {
$ftitle = $Row['ftitle'];
$id = $Row['id'];
$Author = $Row['uname'];
$dhits = $Row['dhits'];
print("<td align=center valign=top width=\"36%\"><a href=\"files.php?id=$id\">$ftitle</a></td>\n");
print("<td align=center valign=top width=\"35%\">$Author</td>\n");
print("<td align=center valign=top width=\"29%\">$dhits</td>\n");
print("</tr>\n");
}
print("</td></table>\n");
$total_results = mysql_result(mysql_query("SELECT COUNT(*) AS NUM FROM file_data"),0);
$total_pages = ceil($total_results / $max_results);
if ($page > 1) {
$prev = ($page - 1);
echo "<a href=\"files.php\"?type=$type2&page=$prev\"><<Previous</A>";
}
FOR($i = 1; $i <= $total_pages; $i++) {
if(($page) != 1) {
} else {
echo "<a href=\"files.php\"?type=$type2&page=$i</a>";
}
}
if($page < $total_pages) {
$next = ($page + 1);
echo "<a href=\"files.php?type=$type2&page=$next\">Next>></a>";
exit();
}
}
}
?>
The probelm i'm having with this code is that when I click on the next link it will display the same results as it did on the first page. Also on the secound page it will not display the prev link (I guess becuase it thinks it stills on the 1 page.
Just in case yall need to know there are 48 records in the (that)database. Also i'm during this on a local computer.