paging

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

paging

Post by kpraman »

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

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:&nbsp;$r[invoiceDate]</td>
									</tr>
									<tr> 
									  <td colspan='4'><div align='right'>Member Id &nbsp;&nbsp;:$r[memberId]</td>
									</tr>
									<tr><td colspan='4' align='right'>Name:  $r[memberFName] &nbsp; $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%'>&nbsp;</td>
									  <td width='44%'>&nbsp;</td>
									  <td colspan='2'>&nbsp;</td>
									</tr>
									<tr> 
									  <td colspan='4'><div align='right'>Total &nbsp;&nbsp;&nbsp;&nbsp;$r[invoiceTotal]</div></td>
									</tr>
								  </table><table><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</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;
				}
I want to display invoiceitems contents inside the above table. How do i do it?

Each invoice id has more than one items.
Post Reply