nenobeto00
04-20-2009, 05:21 AM
Hi. I'm using a select form to fetch data from a db:
Essential parts of code is :
echo("<form action='".$_SERVER['PHP_SELF']."' method='POST' >");
echo("<select name='category'>");
echo("<option value='1'>>MAIN CATEGORY</option>");
/* ........ (subcategories)...more code....*/
/* After that, a query for the database is created , depending on form option: */
/*some code to handle pagination.....*/
$page = $_GET["page"];
$myoffset = 20;
if (!$page) {
$start_index = 0; /* start index for db*/
$page = 1;
}
else {
$start_index = ($page - 1) * $myoffset;
}
if( isset($_POST['category'])
{
$theoption = intval($_POST['category']);
$zquery = "select users.skills from users Where users.parent=".$theoption.") LIMIT $start_index ,$offset ";
$result = mysql_query($zquery);
}
while($row = mysql_fetch_array($result))
{ .....show data......);}
}
?>
Im trying to put 20 records per page and the "NEXT" link is
/* a line from pagination code*/
echo " <a href='".$_SERVER['PHP_SELF']."?page=".($page+1)."'>Next ></a>"
After clicking that link I got the first 20 records but the next page is displayed without data :( and I'd like to get the next set of data displayed on same page.
Id apreciate your help
Thank you!!
Essential parts of code is :
echo("<form action='".$_SERVER['PHP_SELF']."' method='POST' >");
echo("<select name='category'>");
echo("<option value='1'>>MAIN CATEGORY</option>");
/* ........ (subcategories)...more code....*/
/* After that, a query for the database is created , depending on form option: */
/*some code to handle pagination.....*/
$page = $_GET["page"];
$myoffset = 20;
if (!$page) {
$start_index = 0; /* start index for db*/
$page = 1;
}
else {
$start_index = ($page - 1) * $myoffset;
}
if( isset($_POST['category'])
{
$theoption = intval($_POST['category']);
$zquery = "select users.skills from users Where users.parent=".$theoption.") LIMIT $start_index ,$offset ";
$result = mysql_query($zquery);
}
while($row = mysql_fetch_array($result))
{ .....show data......);}
}
?>
Im trying to put 20 records per page and the "NEXT" link is
/* a line from pagination code*/
echo " <a href='".$_SERVER['PHP_SELF']."?page=".($page+1)."'>Next ></a>"
After clicking that link I got the first 20 records but the next page is displayed without data :( and I'd like to get the next set of data displayed on same page.
Id apreciate your help
Thank you!!