hi .. already fix the above problem..
now i get another problem..when i try to expand the above code
still to display the numbering for the items ..
but this time, i need it to display No 1-25 at page 1, No 26-50 at page 2 and so on
i ahve tried, however, i got the problem when it come out with the output like this:
No Name Subject Date
1. mr. x subject 12 nov 2006
1. mr. z subject 13 dec 2006
1. mr. y subject 14 jan 2007
can anybody help me figure this things out.. here is my code
<?php
$stmt = "select m.*, u.* from mailcontent m, user u where m.mailstatusid=3 and postdate < '$lastMonth' and m.mailcategoryid=".$mailCatID." and m.userid=u.userid order by m.postdate desc";
$res =& $db->query($stmt);
echo $numrows = $res->numRows();
$res->free();
$p = (!empty($_GET['pg']))? $_GET['pg']:1;
$perPage = 25;
$pages = ceil($numrows/$perPage);
$from = (($p * $perPage)- $perPage);
//$res =& $db->limitQuery($stmt, $p, $perPage);
$res=& $db->limitQuery($stmt, $from, $perPage);
?>
<dl id="pagetitle" class="clearfix">
<dd class="pageicon"><img src="<?=WWW?>/img/icons/email.png" alt="Archive" /></dd>
<dd class="pagename"><h2>ARCHIVE : <?=$mailCat?></h2></dd>
<?php
if ($numrows==0){
echo "</dl>";
echo "<hr />";
echo "<span class=\"notice\">There are no emails in your archive.</span>";
}
else{
echo "<dd class=\"pagenav\">";
/*-----------------------------
| Paging: Create Paging |
-----------------------------*/
if ($perPage >$pages) {
// -- Pre Navigation -- //
if ($p > 0) {
echo ' ';
} else {
echo '<a href="mail-list.php?show='.$mailCatID.'&pg='.($p-$perPage).'"><img src="'.WWW.'/img/icons/resultset_previous.png" alt="Previous"/></a>';
}
}
echo " (Page $p of $pages) ";
for($i=1; $i<=$pages; $i++){
echo " | ";
if ($p == $i) {
echo $i;
}else {
echo "<a href=\"mail-list.php?show=$mailCatID&pg=$i\">$i</a>";
}
}
// -- Post Navigation -- //
if ($p < ($perPage * ($pages - 1))) {
echo '<a href="mail-list.php?show='.$mailCatID.'&pg='.($p+$perPage).'"><img src="'.WWW.'/img/icons/resultset_next.png" alt="Next" /></a>';
} else {
echo ' ';
}
echo "</dd>";
echo "</dl>";
echo "<hr />";
/*----------------------------------
| Content: Print Mail Listing |
----------------------------------*/
?>
<table>
<tr>
<th>No</th>
<th>From</th>
<th>Subject</th>
<th>Date</th>
</tr>
<?
$n = 0;
//$r=1;
// i put the numbering code here...
for($r=1; $r<=$from; $r++){
if($r == $p)
echo $r;
}
while ($res->fetchInto($rs)){
$bgColor = ($n%2 == 0)? '#FFFFFF':'#F2F2F2';
//echo '<tr style="background:'.$bgColor.'"><td>'.$r.'</td><td><a href="mail-details.php?show='.$mailCatID.'&eid='.$rs['MailID'].'">'.$rs['Title'].' '.$rs['GivenName'].' '.$rs['Surname'].'</a></td><td>'.$rs['Subject'].'</td><td nowrap="nowrap">'.date("d M, Y",strtotime($rs['PostDate'])).'</td></tr>';
echo '<tr style="background:'.$bgColor.'">';
//for($r=1; $r<=$from; $r++){
echo '<td>'.$r.'</td>';
//}
echo '<td><a href="mail-details.php?show='.$mailCatID.'&eid='.$rs['MailID'].'">'.$rs['Title'].' '.$rs['GivenName'].' '.$rs['Surname'].'</a></td><td>'.$rs['Subject'].'</td><td nowrap="nowrap">'.date("d M, Y",strtotime($rs['PostDate'])).'</td>';
echo '</tr>';
$n ++;
//$r ++;
}
}
?></table>
the paging has works well, it just the numbering that gives me headache..
please help