help me on this

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
harshd
Forum Newbie
Posts: 1
Joined: Sun Oct 09, 2016 12:38 am

help me on this

Post by harshd »

Hi sir.pls help me on this.
this code only showing one customer report on one page.but i want to get all the customer details like wise on one report page.so pls help me on this..

Code: Select all

<?php
			
				
			$rview = $_POST['rview'];
			$q = mysql_query("SELECT cus_name FROM cus WHERE cus_id = '$cus_id'");
			$r = mysql_fetch_assoc($q);
			$cus_name = $r['cus_name'];
			echo "<p><strong>Customer:</strong> {$cus_name}</p>";
			if($rview == "products"){
?>
<table width="98%"  border="1px" cellspacing="0" cellpadding="3px" style="border:0px solid #000; border-collapse:collapse;" align="center">
	<tr style="font-weight:bold;">
		<td style="border-right:0; border-left:0;">Code</td>
		<td style="border-right:0; border-left:0;">Description</td>
		<td style="border-right:0; border-left:0;">Unit</td>
		<td style="border-right:0; border-left:0;"><div align="right">Qty</div></td>
		<td style="border-right:0; border-left:0;"><div align="right">Gross Value</div></td>
	</tr>
	<?php
		$total_qty = 0;
		$total_gross = 0;
		$q = mysql_query("SELECT itm_code, itm_des, itm_unit, SUM(ini_qty), SUM(ini_qty * ini_price) AS gross 
		FROM itm, inv, inv_itm 
		WHERE itm_id = ini_itm AND inv_id = ini_trn AND inv_cus = '$cus_id' AND inv_date BETWEEN '$from' AND '$to' GROUP BY ini_itm");
		while($r = mysql_fetch_assoc($q)){
			$itm_code = $r['itm_code'];
			$itm_des = $r['itm_des'];
			$itm_unit = $r['itm_unit'];
			$itm_qty = $r['SUM(ini_qty)'];
			$gross_val = $r['gross'];
			echo "<tr>
				<td style=\"border-right:0; border-left:0;\">{$itm_code}</td>
				<td style=\"border-right:0; border-left:0;\">{$itm_des}</td>
				<td style=\"border-right:0; border-left:0;\">{$itm_unit}</td>
				<td style=\"border-right:0; border-left:0;\"><div align=\"right\">".number_format($itm_qty,2,".",",")."</div></td>
				<td style=\"border-right:0; border-left:0;\"><div align=\"right\">".number_format($gross_val,2,".",",")."</div></td>
			</tr>\n";
			$total_qty += $itm_qty;
			$total_gross += $gross_val;
		}
	?>
	<tr style="font-weight:bold;">
		<td style="border-right:0; border-left:0;">&nbsp;</td>
		<td style="border-right:0; border-left:0;">&nbsp;</td>
		<td style="border-right:0; border-left:0;">&nbsp;</td>
		<td style="border-right:0; border-left:0;"><div align="right"><?php echo number_format($total_qty,2,".",","); ?></div></td>
		<td style="border-right:0; border-left:0;"><div align="right"><?php echo number_format($total_gross,2,".",","); ?></div></td>
	</tr>
</table>
<?php
Attachments
Untitled.png
Untitled.png (9.13 KiB) Viewed 1694 times
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: help me on this

Post by Christopher »

The condition in your SELECT statement " AND inv_cus = '$cus_id' " is what limits the results to a single customer.
(#10850)
Post Reply