problemer med paging script
Jeg har hentet et script som jeg ikk kan få til at fungere så vil hører om der er nogen der kan hjælpe. i kan se hvad den gør her.. www.play4all.dk/paging.phpdette er scriptet
---------------------------------------------------
<?
//REMEMBER TO CONNECT TO DATABASE!
include("includes/dbconnect.php");
//**EDIT TO YOUR TABLE NAME, ECT.
$t = mysql_query("SELECT * FROM channels");
if(!$t) die(mysql_error());
$a = mysql_fetch_object($t);
$total_items = mysql_num_rows($t);
$limit = $_GET['limit'];
$type = $_GET['type'];
$page = $_GET['page'];
//set default if: $limit is empty, non numerical, less than 10, greater than 50
if((!$limit) || (is_numeric($limit) == false) || ($limit < 10) || ($limit > 50)) {
$limit = 10; //default
}
//set default if: $page is empty, non numerical, less than zero, greater than total available
if((!$page) || (is_numeric($page) == false) || ($page < 0) || ($page > $total_items)) {
$page = 1; //default
}
//calcuate total pages
$total_pages = ceil($total_items / $limit);
$set_limit = $page * $limit - ($limit);
//query: **EDIT TO YOUR TABLE NAME, ECT.
$q = mysql_query("SELECT * FROM channels LIMIT $set_limit, $limit");
if(!$q) die(mysql_error());
$err = mysql_num_rows($q);
if($err == 0) die("No matches met your criteria.");
//Results per page: **EDIT LINK PATH**
echo("
<a href=http://www.play4all.dk.php?cat=$cat&limit=10&page=1>10</a> |
<a href=http://www.play4all.dk.php?cat=$cat&limit=25&page=1>25</a> |
<a href=http://www.play4all.dk.php?cat=$cat&limit=50&page=1>50</a>");
//show data matching query:
while($code = mysql_fetch_object($q)) {
echo("item: ".$code->title."<BR>");
}
$cat = urlencode($cat); //makes browser friendly
//prev. page: **EDIT LINK PATH**
$prev_page = $page - 1;
if($prev_page >= 1) {
echo("<b><<</b> <a href=http://www.play4all.dk.php?cat=$cat&limit=$limit&page=$prev_page><b>Prev.</b></a>");
}
//Display middle pages: **EDIT LINK PATH**
for($a = 1; $a <= $total_pages; $a++)
{
if($a == $page) {
echo("<b> $a</b> | "); //no link
} else {
echo(" <a href=http://www.play4all.dk.php?cat=$cat&limit=$limit&page=$a> $a </a> | ");
}
}
//next page: **EDIT THIS LINK PATH**
$next_page = $page + 1;
if($next_page <= $total_pages) {
echo("<a href=http://www.play4all.dk.php?cat=$cat&limit=$limit&page=$next_page><b>Next</b></a> > >");
}
//all done
?>
