paging
Posted: Thu Dec 21, 2006 9:09 am
tables
invoice
invoiceitems
Invoice has the following fields,
invoiceId,memberId,invoiceTotal,invoiceDate
invoiceitems has the following fields,
invoiceId,item,amount,
for example if 4 items are purchased.
invoice table
invoiceId memberId invoiceTotal invoiceDate
1 1 100 12/21/06
invoiceitems table
invoiceId item amount
1 100 25
1 101 25
1 102 25
1 103 25
paging code
I want to display invoiceitems contents inside the above table. How do i do it?
Each invoice id has more than one items.
invoice
invoiceitems
Invoice has the following fields,
invoiceId,memberId,invoiceTotal,invoiceDate
invoiceitems has the following fields,
invoiceId,item,amount,
for example if 4 items are purchased.
invoice table
invoiceId memberId invoiceTotal invoiceDate
1 1 100 12/21/06
invoiceitems table
invoiceId item amount
1 100 25
1 101 25
1 102 25
1 103 25
paging code
Code: Select all
$num = $_GET['num'];
if(empty($num)){
$num = 1;
};
$limit = 6;
$start = ($num-1)*$limit;
$start = round($start,0);
$contents="<table border='0' width='100%' align='' cellspacing='1' cellpadding='6'><tr align='center'><td>ORDERS</td></tr></table>";
$query = "SELECT * FROM invoice,members GROUP BY invoiceId ORDER BY invoiceId DESC LIMIT $start, $limit";
$result = mysql_query($query);
$num=mysql_num_rows($result);
if($num==0)
{
$message="<table cellspacing='1' cellpadding='6'><tr><td>THERE ARE NO RECORDS TO DISPLAY</td></tr></table>";
}
while ($r = mysql_fetch_array($result)){
$contents.="<table width='100%' height='76' border='1' align='center' dwcopytype='CopyTableRow'>
<tr>
<td colspan='3' align='left'>Order Id $r[invoiceId]</td>
<td width='18%'>Date: $r[invoiceDate]</td>
</tr>
<tr>
<td colspan='4'><div align='right'>Member Id :$r[memberId]</td>
</tr>
<tr><td colspan='4' align='right'>Name: $r[memberFName] $r[memberLName]</div></td></tr>
<tr>
<td width='23%'><div align='center'>Picture ID</div></td>
<td width='44%'><div align='center'>Picture Name</div></td>
<td colspan='2'><div align='center'>Price</div></td>
</tr>
<tr>
<td width='23%'> </td>
<td width='44%'> </td>
<td colspan='2'> </td>
</tr>
<tr>
<td colspan='4'><div align='right'>Total $r[invoiceTotal]</div></td>
</tr>
</table><table><tr><td> </td></tr><tr><td> </td></tr><tr><td> </td></tr></table>";
}
$totalpages = mysql_num_rows(mysql_query("SELECT * from `invoice`"));
$totalpages = ceil($totalpages / $limit);
$totalpages = round($totalpages,0);
$c = 0;
$contents.="<br>";
while($c<$totalpages){
$page = $c + 1;
if($_GET['num']==$page){
$pagenav.="[$page] ";
}else{
$pagenav.="<a href=?num=$page>[$page] </a>";
}
$c = $c+1;
}Each invoice id has more than one items.