Hi,
I'm having problems with paging links not working correctly.
My web form query returns an initial correct page with the correct numbers for the paging results..however when the Next button or #2 or subsequent # is clicked...ALL records are returned, not just those limiited by the form search info. i.e. if 12 records returned I'm getting 1 2 Next displayed which is correct. Clicking 2 or Next returns ALL records (however, also with correct #'s for links and these links work correctly). How do I prevent ALL records from being returned and get these Next links to display the following records for only what was queried?
Here's the code basically:
$sqlcount queries against form data and returns correctly.
$sql_countresult = mysql_query($sqlcount, $connection) or die ("Couldnt execute query count");
$totalrows = mysql_num_rows($sql_countresult);
if(empty($page)){
$page=1;
}
$limitvalue1 = $page*$limit-($limit);
if ($user_id) {
$sql = SELECT .....
} else {
$sql = SELECT...LIMIT $limitvalue1, $limit";
}
$sql_result = mysql_query($sql, $connection)
**records displayed**
**now paging**
if($page !=1) {
$pageprev = $page -1;
echo "<a href=http://www.phpbuilder.com/board/archive/index.php/\"$PHP_SELF?page=$pageprev\"> PREV </a>";
}
$numofpages = $totalrows/$limit;
if ($numofpages > 1) {
for($i=1;$i<$numofpages;$i++) {
echo "<a href=\"$PHP_SELF?page=$i\"> $i </a>";
}
}
if($totalrows%$limit !=0) {
echo "<a href=\"$PHP_SELF?page=$i\"> $i </a>";
}
if (($totalrows-($limit*$page)) > 0) {
$pagenext = $page +1;
echo "<a href=\"$PHP_SELF?page=$pagenext\"> NEXT </a>";
}
Any help greatly appreciated!!
gary
I'm having problems with paging links not working correctly.
My web form query returns an initial correct page with the correct numbers for the paging results..however when the Next button or #2 or subsequent # is clicked...ALL records are returned, not just those limiited by the form search info. i.e. if 12 records returned I'm getting 1 2 Next displayed which is correct. Clicking 2 or Next returns ALL records (however, also with correct #'s for links and these links work correctly). How do I prevent ALL records from being returned and get these Next links to display the following records for only what was queried?
Here's the code basically:
$sqlcount queries against form data and returns correctly.
$sql_countresult = mysql_query($sqlcount, $connection) or die ("Couldnt execute query count");
$totalrows = mysql_num_rows($sql_countresult);
if(empty($page)){
$page=1;
}
$limitvalue1 = $page*$limit-($limit);
if ($user_id) {
$sql = SELECT .....
} else {
$sql = SELECT...LIMIT $limitvalue1, $limit";
}
$sql_result = mysql_query($sql, $connection)
**records displayed**
**now paging**
if($page !=1) {
$pageprev = $page -1;
echo "<a href=http://www.phpbuilder.com/board/archive/index.php/\"$PHP_SELF?page=$pageprev\"> PREV </a>";
}
$numofpages = $totalrows/$limit;
if ($numofpages > 1) {
for($i=1;$i<$numofpages;$i++) {
echo "<a href=\"$PHP_SELF?page=$i\"> $i </a>";
}
}
if($totalrows%$limit !=0) {
echo "<a href=\"$PHP_SELF?page=$i\"> $i </a>";
}
if (($totalrows-($limit*$page)) > 0) {
$pagenext = $page +1;
echo "<a href=\"$PHP_SELF?page=$pagenext\"> NEXT </a>";
}
Any help greatly appreciated!!
gary