Jump to content

paging 10 new records at a time?!


jarv

Recommended Posts

ok here is my code

<?php
include_once("config.php");
include_once("functions.php");
// Check user logged in already:
checkLoggedIn("yes");
//doCSS(); 
$offset = $_REQUEST["start"];
$rowsPerPage = $_REQUEST["count"]; 
$query  = "SELECT * FROM pubs LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die(mysql_error().'<br>SQL: ' . $query);  
// start main page
while($row = mysql_fetch_array($result)){
$PUBID = $row['PUBID'];
$RSPUBNAME = $row['RSPUBNAME'];
$RSADDRESS = $row['RSADDRESS']; 
$RSPOSTCODE = $row['RSPOSTCODE'];
$RSTEL = $row['RSTEL'];
$RSTOWN = $row['RSTOWN'];
$RSCOUNTY = $row['RSCOUNTY'];
// how many rows we have in database
// print the link to access each page
$self = $_SERVER['PHP_SELF'];
$next = "<li><a href=\"all.php?start=20&count=10\" target=\"_replace\">View More</a></li>";
//div container of header and information
echo <<<EOF
  <li><a href="#">$RSPUBNAME</a></li>
EOF;
if	($_SESSION["RSUSER"] == "admin") 
{
echo "<a href=\"edit.php?PUBID=$PUBID\" class=\"small\">edit this pub</a>";
}
}
echo $next;
?>

 

the first time I click on View More it works, if i do it again, it just shows the previous 10 records, please help?

 

Link to comment
https://forums.phpfreaks.com/topic/208778-paging-10-new-records-at-a-time/
Share on other sites

$offset = (isset($_GET['start'])) ? (int)$_GET["start"] : 0;
$rowsPerPage = (isset($_GET['count'])) ? (int)$_GET["count"] : 10; 

 

 

$next = "<li><a href=\"all.php?start=" . ($offset + $rowsPerPage) . "&count={$rowsPerPage}\" target=\"_replace\">View More</a></li>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.