Dit is het script.. Het is een page flipper.
Ik blijf echter maar deze foutmelding krijgen:
Parse error: syntax error, unexpected $end in C:\wamp\www\pageflipper\pagination.php on line 113
Ik blijf echter maar deze foutmelding krijgen:
Parse error: syntax error, unexpected $end in C:\wamp\www\pageflipper\pagination.php on line 113
PHP:
<?php
$link = mysql_connect('localhost','root')
or die("Error connecting to Database: " . mysql_error());
mysql_select_db('user_result') or
die("Error Selecting Database: " . mysql_error());
//**EDIT TO YOUR TABLE NAME, ETC.
$t = mysql_query("SELECT count(*) FROM 'result' as cnt'");
if(!$t){
die("Error quering the Database: " . mysql_error());
}
$a = mysql_fetch_object($t);
$total_items = $a->cnt;
echo "Total Number of records in Database: ".$total_items;
$limit= $_GET['limit'];
$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
}
//calculate total pages
$total_pages = ceil($total_items / $limit);
$set_limit = $page * $limit - ($limit);
//query: **EDIT TO YOUR TABLE NAME, ETC.
$q = mysql_query("SELECT * FROM 'result'
LIMIT $set_limit, $limit");
if(!$q) die(mysql_error());
$no_row = mysql_num_rows($q);
if($no_row == 0) die("No matches met your criteria.");
//Results per page: **EDIT LINK PATH**
echo("
<a href=http://localhost/pageflipper/pagination.php?limit=10&page=1>
10</a> |
<a href=http://localhost/pageflipper/pagination.php?limit=25&page=1>
25</a> |
<a href=http://localhost/pageflipper/pagination.php?limit=50&page=1>
50</a>
");
//show data matching query:
while($code = mysql_fetch_object($q)) {
//print your data here.
echo("————————————–");
echo("Name: ".$code->user_name."<BR/>");
echo("Math Marks: ".$code->math_marks."<BR/>");
echo("Physics Marks: ".$code->phy_marks."<BR/>");
echo("————————————–");
}
//prev. page: **EDIT LINK PATH**
$prev_page = $page - 1;
if($prev_page >= 1) {
echo("<b><<</b> <a href=http://localhost/pageflipper/pagination.php?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://localhost/pageflipper/pagination.php?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://localhost/pageflipper/pagination.php?limit=$limit&page=$next_page><b>Next</b> > </a>');
}
?>