hi everyone,
i have 2 problems which makes me to stuck inbetween my application..
my first issue is:
i already used get method to pass variable values between pages which is working fine till now as follows:
$frmDate=trim($_GET);
$toDate=trim($_GET);
$time=trim($_GET);
$incoming=$_GET;
echo "<a href=\"outgoing.php?optSingle=".$c."&beg=".$frmDate."&datEnd=".$toDate."&inTxt=".$incoming."&flr=".$flr."&page=1\" ></a>";
but how can i use post method and pass values between pages...
My second issue:
i have used pagination in php.. am displaying 10 records per page and printind result as "1 - 10 records of 106 records".. but problem arises at last page where instead of "101 - 106 of 106 records" it showing as " 101 - 110 of 106 records"...
here is my code:
$query="SELECT * FROM calldetail WHERE (";
for($i=0;$i<count($r);$i++)
{
if ($r[$i][1]==null)
{
if ($i>0)
$query.=" OR";
$query.=" (CallTermination ='".$r[$i][0]."')";
}
else
{
if ($i>0)
$query.=" OR";
$query.=" (CallTermination BETWEEN '".$r[$i][0]."' AND '".$r[$i][1]."')";
}
} // end of for loop
$query.=") and CallFlag='L' AND CallDate BETWEEN '".$frmDate1."' AND '". $toDate1."' ORDER BY ";
if ($dat=='CallDate desc' or $dat=='CallDate asc')
$query.=$dat;
$query.=" LIMIT $offset, $rowsPerPage";
$c1='&optDat';
tab($query,$connection,$frmDate,$toDate,$incoming,$dat,$c1,$offset,$rowsPerPage,$pageNum,$row['CallFlag'],$dial,$receive);
$query="SELECT count(CallDate) as numrows FROM calldetail WHERE (";
for($i=0;$i<count($r);$i++) {
if ($r[$i][1]==null)
{
if ($i>0)
$query.=" OR";
$query.=" (CallTermination ='".$r[$i][0]."')";
}
else
{
if ($i>0)
$query.=" OR";
$query.=" (CallTermination BETWEEN '".$r[$i][0]."' AND '".$r[$i][1]."')";
}
} //end of for loop
$query.=")and CallFlag='L' AND CallDate BETWEEN '".$frmDate1."' AND '". $toDate1."' ORDER BY CallTermination ASC";
// how many rows we have in database
$result = mysql_query($query) or die('database query error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
}
// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);
// print the link to access each page
$self = $_SERVER['PHP_SELF'];
$nav = '';
for($page = 1; $page <= $maxPage; $page++)
{
if ($page == $pageNum)
{
$nav .= " $page "; // no need to create a link to current page
}
else
{
$nav .= " <a href=\"$self?beg=".$frmDate."&datEnd=".$toDate."&inTxt=".$incoming."&page=$page\">$page</a> ";
}
}// end of for loop
// creating previous and next link plus the link to go straight to the first and last page
if ($pageNum > 1) {
//this is activated from page 2
$page = $pageNum - 1;
$prev = " <a href=\"$self?beg=".$frmDate."&datEnd=".$toDate."&inTxt=".$incoming."&page=$page\"><img style='border-style:none' src='img/previous.gif'></a> ";
$first = " <a href=\"$self?beg=".$frmDate."&datEnd=".$toDate."&inTxt=".$incoming."&page=1\"><img style='border-style:none' src='img/firstenable.gif'></a> ";
}
else {
//this is for first page
$prev = '<img style="border-style:none" src="img/previous.gif">'; //1st page; we're on page one, don't print previous link
$first = '<img style="border-style:none" src="img/firstdisable.gif">'; // nor the first page link
}
if ($pageNum < $maxPage) {
$page = $pageNum + 1;
$next = " <a href=\"$self?beg=".$frmDate."&datEnd=".$toDate."&inTxt=".$incoming."&page=$page\"><img style='border-style:none' src='img/next.gif'></a> ";
$last = " <a href=\"$self?beg=".$frmDate."&datEnd=".$toDate."&inTxt=".$incoming."&page=$maxPage\"><img style='border-style:none' src='img/lastenable.gif'></a> ";
}
else {
$next = '<img style="border-style:none" src="img/next.gif">'; // we're on the last page, don't print next link
$last = '<img style="border-style:none" src="img/lastdisable.gif">'; // nor the last page link
}
// print the navigation link
echo '<br/><center>';
// and close the database connection
if($numrows==0)
{
echo "</br></br>No Records";
}
else
{
echo $first . $prev . $next . $last;
echo "<p >" .'Showing <font color="red">'. ($offset+1) . " - " . ($offset+$rowsPerPage) . "</font> of ". $numrows . " Records" ."</p>";
}
can anyone give some idea on how to do it?