mivbinfotech
asked on
next page link is not working
hai I m able to display the results from my database with 10 results per row..but i m not able to move to next page ..ie.,the next link is not doing anything.
I have attached my code..could any one help me out..its urgent...thks in advance
<?
include_once("connect.php" );
include_once("config.inc.p hp");
include_once( "include/class.TemplatePow er.inc.php " );
$tpl = new TemplatePower("template/ou rppldtl.ht m" ); // Template Object
$tpl->assignInclude( "CHARSET_FILE", "charset.php" ); // Dynamic file inclusion
global $dbNew,$HTTPURL,$char,$sea rch; // declaring global variables
$tpl->prepare();
$tpl->assign("_ROOT.HTTPUR L",$HTTPUR L);
$tpl->assign("char",$char) ;
$query="select * from ".TBLCONTENT." where pagename = 'oppldtl'";
$res = $dbNew->Execute($query);
if ($res) { // IF STARTS
$arr = $res->FetchRow();
$content = nl2br($arr['contents']);
} // IF ENDS
$tpl->assign("ourpeopledtl content",$ content);
/************************* ********** ********** ********** ********** ********** ********** ********** ********** ********** ***/(my issue starts from here)
//This code created by Shahabudeen M.Y.., for Mivbinfotech.com
//This checks to see if there is a page number. If not, it will set it to page 1
if (!(isset($pagenum)))
{
$pagenum = 1;
}
//Here we count the number of results
//Edit $data to be your query
$data = "SELECT * FROM ".TBLOURPEOPLE." where pplstatus ='ACTIVE'";
$res_cat = $dbNew->Execute($data);
//$totalrows = $res_cat->PO_RecordCount() ;
$rows = $res_cat->PO_RecordCount() ;
//This is the number of results displayed per page
$page_rows = 10;
//This tells us the page number of our last page
$last = ceil($rows/$page_rows);
//this makes sure the page number isn't below one, or more than our maximum pages
if ($pagenum < 1)
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}
//This sets range that we will display in our query
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;
//This is your query again, the same one... the only difference is we add $max into it
$data_p ="SELECT * FROM ".TBLOURPEOPLE." where pplstatus ='ACTIVE' $max";
$res_cat1 = $dbNew->Execute($data_p);
//This is where you display your query results
while($info = $res_cat1->FetchRow())
{
echo $info['pplfirstname'];
echo " ";
echo $info['ppllastname'];
echo "<br>";
echo "<br>";
}
echo "<p>";
// This shows the user what page they are on, and the total number of pages
echo " --Page $pagenum of $last-- <p>";
// First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page.
if ($pagenum == 1)
{
}
else
{
echo " <a href=$PHP_SELF?pagenum=1> <<-First</a> ";
echo " ";
$previous = $pagenum-1;
echo " <a href=$PHP_SELF?pagenum=$pr evious> <-Previous</a> ";
}
//just a spacer
echo " ---- ";
//This does the same as above, only checking if we are on the last page, and then generating the Next and Last links
if ($pagenum == $last)
{
}
else {
$next = $pagenum+1;
echo " <a href='{$_SERVER['PHP_SELF' ]}?pagenum =$next'>Ne xt -></a> ";
echo " ";
echo " <a href='{$_SERVER['PHP_SELF' ]}?pagenum =$last'>La st ->></a> ";
}
?>
</p>
</body>
</html>
I have attached my code..could any one help me out..its urgent...thks in advance
<?
include_once("connect.php"
include_once("config.inc.p
include_once( "include/class.TemplatePow
$tpl = new TemplatePower("template/ou
$tpl->assignInclude( "CHARSET_FILE", "charset.php" ); // Dynamic file inclusion
global $dbNew,$HTTPURL,$char,$sea
$tpl->prepare();
$tpl->assign("_ROOT.HTTPUR
$tpl->assign("char",$char)
$query="select * from ".TBLCONTENT." where pagename = 'oppldtl'";
$res = $dbNew->Execute($query);
if ($res) { // IF STARTS
$arr = $res->FetchRow();
$content = nl2br($arr['contents']);
} // IF ENDS
$tpl->assign("ourpeopledtl
/*************************
//This code created by Shahabudeen M.Y.., for Mivbinfotech.com
//This checks to see if there is a page number. If not, it will set it to page 1
if (!(isset($pagenum)))
{
$pagenum = 1;
}
//Here we count the number of results
//Edit $data to be your query
$data = "SELECT * FROM ".TBLOURPEOPLE." where pplstatus ='ACTIVE'";
$res_cat = $dbNew->Execute($data);
//$totalrows = $res_cat->PO_RecordCount()
$rows = $res_cat->PO_RecordCount()
//This is the number of results displayed per page
$page_rows = 10;
//This tells us the page number of our last page
$last = ceil($rows/$page_rows);
//this makes sure the page number isn't below one, or more than our maximum pages
if ($pagenum < 1)
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}
//This sets range that we will display in our query
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;
//This is your query again, the same one... the only difference is we add $max into it
$data_p ="SELECT * FROM ".TBLOURPEOPLE." where pplstatus ='ACTIVE' $max";
$res_cat1 = $dbNew->Execute($data_p);
//This is where you display your query results
while($info = $res_cat1->FetchRow())
{
echo $info['pplfirstname'];
echo " ";
echo $info['ppllastname'];
echo "<br>";
echo "<br>";
}
echo "<p>";
// This shows the user what page they are on, and the total number of pages
echo " --Page $pagenum of $last-- <p>";
// First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page.
if ($pagenum == 1)
{
}
else
{
echo " <a href=$PHP_SELF?pagenum=1> <<-First</a> ";
echo " ";
$previous = $pagenum-1;
echo " <a href=$PHP_SELF?pagenum=$pr
}
//just a spacer
echo " ---- ";
//This does the same as above, only checking if we are on the last page, and then generating the Next and Last links
if ($pagenum == $last)
{
}
else {
$next = $pagenum+1;
echo " <a href='{$_SERVER['PHP_SELF'
echo " ";
echo " <a href='{$_SERVER['PHP_SELF'
}
?>
</p>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$pagenum is assigned globally via a GET request in a link. If it hasn't been defined, it asssumes '1'.
to begin with, your current page var is $pagenum
Then you set $pagenum the maximum possible page.
Then later you even check to see if they're equal! Of course they're equal, you set them to be the same thing.
That's my first impression anyhow. Fix that, and then if it's still broke, post your new code here.