Hi all..can somebody tell me how to do this..
I have two tables, po and po_item..
There is one to many relationship.
PO
po_id
po_no
po_date
po_item
item_id
po_no
item
qty
unit_price
total
Now i want to display all data from po and a total price for every po that i sum from po_item.I mean sum total from po_item group by po_no.
This is what i have done so far..
PHP Code:<?
$query = "SELECT * FROM po";
$result=mysql_query($query);
if (!$result)
die("<p>ERROR number". mysql_errno(). ": ".mysql_error() ."</p>");
$num_results=mysql_num_rows($result);
?>Can someone give me an idea or way how to do this..thanks in advancePHP Code:<?
// Display data
<table width="95%" border="1" align="center" cellpadding="3" cellspacing="0" class="title" bordercolor="#CCCCCC">
<tr>
<td align="center" colspan="9"> </td>
</tr>
<tr>
<td width="19%" align="center"> P.O NO </td>
<td width="11%"><font face="Tahoma">DATE</font></td><td> TOTAL PRICE </td>
</tr>
<? for ($i=0; $i < $num_results; $i++){
$row=mysql_fetch_array($result);
?>
<tr>
<td><? echo $row['po_no']?></td>
<td><? echo $row['po_date']</td>
<td> </td>
</tr>
<? } ?>
</table>




Reply With Quote