order table
orderid orderdate cust_name address itemno itemname qty price totalprice
54 12/09/2008 xxx yyy 5 cake 5 5 25
54 12/09/2008 xxx yyy 3 choclate 5 3 15
55 13/09/2008 www uuu 7 rice 6 6 36
55 13/09/2008 www uuu 8 biscut 1 10 10
55 13/09/2008 www uuu 9 flower 4 4 16
56 17/09/2008 sss ooo 7 rice 5 6 30
if i search the order date base(only month-9) from the data base,
i want to display following like in php page(like report)
if i select september(9), i want to dipslay in php page in table format,how can i achive it, i tried in nested while loops,
but it not worked?
cust_name:xxx address:yyy
orderdate:12/09/2008
orderid orderdate cust_name address itemno itemname qty price totalprice
54 12/09/2008 xxx yyy 5 cake 5 5 25
54 12/09/2008 xxx yyy 3 choclate 5 3 15
total 40
cust_name:www address:uuu
orderdate:13/09/2008
orderid orderdate cust_name address itemno itemname qty price totalprice
55 13/09/2008 www uuu 7 rice 6 6 36
55 13/09/2008 www uuu 8 biscut 1 10 10
55 13/09/2008 www uuu 9 flower 4 4 16
total 62
cust_name:sss address:ooo
orderdate:17/09/2008
orderid orderdate cust_name address itemno itemname qty price totalprice
56 17/09/2008 sss ooo 7 rice 5 6 30
total 30
--------------------------------------------------------------------------------------------------------
this is my code in php but it is not working properly(i use Microsoft Sql server 2005 , for database, i use stored procedures)
if (isset($_POST['btnsubmit']))
{
$selectmonth=$_POST['month'];
$selectyear=$_POST['year'];
$owner_id=13;
$_SESSION['month']=$selectmonth;
$_SESSION['year']=$selectyear;
$_SESSION['owner_id']=$owner_id;
$exec=mssql_init("usp_sbh_get_order_report_cust_details");
mssql_bind($exec,"@sbOrdMonth",$selectmonth,SQLINT4);
mssql_bind($exec,"@sbOrdYear",$selectyear,SQLINT4);
mssql_bind($exec,"@sbOwnerId",$owner_id,SQLINT4);
$result=mssql_execute($exec);
$exec1=mssql_init("usp_sbh_get_order_report");
mssql_bind($exec1,"@sbOrdMonth",$selectmonth,SQLINT4);
mssql_bind($exec1,"@sbOrdYear",$selectyear,SQLINT4);
mssql_bind($exec1,"@sbOwnerId",$owner_id,SQLINT4);
$result1=mssql_execute($exec1);
$rows=mssql_num_rows($result);
$rows1=mssql_num_rows($result1);
if ($rows > 0 && $rows1 > 0)
{
//while($row=mssql_fetch_array($result))
for($i=0;$i<$rows;$i++)
{
$row=mssql_fetch_array($result);
echo '<table border="0" cellpadding="1" cellspacing="1">';
echo '<tr><td align="left"><b>Airline Name:</b></td><td align="left">'.$row["air_name"].'</td>
<td align="left"><b>Order Date:</b></td><td align="left">'.date("m-d-Y",strtotime($row["order_dt"])).'</td></tr>';
echo '<tr><td align="left"><b>Customer Name:</b></td><td align="left">'.$row["cust_ship_lname"]." ".$row["cust_ship_fname"].'</td><td align="left"><b>Customer Phone:</b></td><td align="left">'.$row["cust_phone"].'</td></tr>';
echo '<tr><td align="left" valign="top"><b>Shipping Address:</td><td>'.$row["cust_ship_addr1"].'<br/>'.
$row["cust_ship_addr2"].'<br/>'.$row["cust_ship_city"].'<br/>'.$row["cust_ship_state"].'<br/>'.$row["cust_ship_country"]." ".$row["cust_ship_zip"].'</td><td align="left" valign="top"><b>Customer Mail:</b></td><td align="left" valign="top">'.$row["cust_ship_email"].'</td></tr></table>';
$orderid=$row["order_id"];
echo $orderid;
echo '<table border="1" cellpadding="1" cellspacing="1"><tr><td nowrap><b>Order ID</b></td><td nowrap><b>Product Code</b></td><td nowrap><b>Product Title</b></td><td><b>Category</b></td><td><b>Status</b></td><td><b>Quantity</b></td><td nowrap><b>Vendor Price</b><td nowrap><b>Amount</b><td nowrap><b>SkyBuy Price</b><td nowrap><b>Amount</b></td>';
for($j=0;$j<$rows1;$j++)
{
$row1=mssql_fetch_array($result1);
if ($orderid==$row1["order_id"])
{
echo '<tr><td>'.$row1["order_id"].'</td>';
echo '<td>'.$row1["prod_code"].'</td>';
echo '<td>'.$row1["prod_title"].'</td>';
echo '<td>'.$row1["cate_name"].'</td>';
echo '<td>'.$row1["status"].'</td>';
echo '<td align="right">'.$row1["qty"].'</td>';
echo '<td align="right">'.$row1["vend_price"].'</td>';
$total_vend_amount=$row1["qty"]*$row1["vend_price"];
echo '<td align="right">'.number_format($total_vend_amount,2).'</td>';
echo '<td align="right">'.$row1["sbh_price"].'</td>';
$total_sbh_amount=$row1["qty"]*$row1["sbh_price"];
echo '<td align="right">'.number_format($total_sbh_amount,2).'</td>';
$total_qty+=$row1["qty"];
$total_vend_price+=$total_vend_amount;
$total_sbh_price+=$total_sbh_amount;
}
}
$total_vend_price=number_format($total_vend_price,2);
$total_sbh_price=number_format($total_sbh_price,2);
echo '<tr><td colspan="5" align="right"><b>Total</b></td><td align="right">'.$total_qty.'</td><td></td><td align="right">'.$total_vend_price.'</td><td></td><td align="right">'.$total_sbh_price.'</td></tr>';
}
echo '<tr><td colspan="10" align="center"><a href="sbhorderprint.php"><img src="images/print.png" border="0" height="35px" width="35px" alt="Print" title="Print"></a><a href="sbhorderpdf.php"><img src="images/pdf.jpg" border="0" height="35px" width="35px" alt="Export PDF" title="Export PDF"><a href="sbhorderpdfmail.php"><img src="images/email.gif" border="0" height="25px" width="25px" alt="Send Email" title="Send Email"></a></table>';
}
else
{
echo '<table><tr><td align="center"><strong>No results Found</strong></td></tr></table>';
}
}
here i use two sp's for retriving records,
my corde displays
only first order details,customer details
second record, display only customer details, not order item details
third also display like seond,
how display like example table, using php code what i gave