PHP table display

Reply

Join Date: Sep 2008
Posts: 18
Reputation: php2sheik is an unknown quantity at this point 
Solved Threads: 1
php2sheik php2sheik is offline Offline
Newbie Poster

PHP table display

 
0
  #1
Sep 27th, 2008
  1. order table
  2. orderid orderdate cust_name address itemno itemname qty price totalprice
  3. 54 12/09/2008 xxx yyy 5 cake 5 5 25
  4. 54 12/09/2008 xxx yyy 3 choclate 5 3 15
  5. 55 13/09/2008 www uuu 7 rice 6 6 36
  6. 55 13/09/2008 www uuu 8 biscut 1 10 10
  7. 55 13/09/2008 www uuu 9 flower 4 4 16
  8. 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?

  1. cust_name:xxx address:yyy
  2. orderdate:12/09/2008
  3. orderid orderdate cust_name address itemno itemname qty price totalprice
  4. 54 12/09/2008 xxx yyy 5 cake 5 5 25
  5. 54 12/09/2008 xxx yyy 3 choclate 5 3 15
  6. total 40
  7.  
  8.  
  9. cust_name:www address:uuu
  10. orderdate:13/09/2008
  11. orderid orderdate cust_name address itemno itemname qty price totalprice
  12. 55 13/09/2008 www uuu 7 rice 6 6 36
  13. 55 13/09/2008 www uuu 8 biscut 1 10 10
  14. 55 13/09/2008 www uuu 9 flower 4 4 16
  15. total 62
  16.  
  17. cust_name:sss address:ooo
  18. orderdate:17/09/2008
  19. orderid orderdate cust_name address itemno itemname qty price totalprice
  20. 56 17/09/2008 sss ooo 7 rice 5 6 30
  21. 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)

  1. if (isset($_POST['btnsubmit']))
  2. {
  3.  
  4. $selectmonth=$_POST['month'];
  5. $selectyear=$_POST['year'];
  6. $owner_id=13;
  7.  
  8.  
  9. $_SESSION['month']=$selectmonth;
  10.  
  11. $_SESSION['year']=$selectyear;
  12. $_SESSION['owner_id']=$owner_id;
  13.  
  14. $exec=mssql_init("usp_sbh_get_order_report_cust_details");
  15. mssql_bind($exec,"@sbOrdMonth",$selectmonth,SQLINT4);
  16. mssql_bind($exec,"@sbOrdYear",$selectyear,SQLINT4);
  17. mssql_bind($exec,"@sbOwnerId",$owner_id,SQLINT4);
  18. $result=mssql_execute($exec);
  19.  
  20. $exec1=mssql_init("usp_sbh_get_order_report");
  21. mssql_bind($exec1,"@sbOrdMonth",$selectmonth,SQLINT4);
  22. mssql_bind($exec1,"@sbOrdYear",$selectyear,SQLINT4);
  23. mssql_bind($exec1,"@sbOwnerId",$owner_id,SQLINT4);
  24. $result1=mssql_execute($exec1);
  25.  
  26. $rows=mssql_num_rows($result);
  27. $rows1=mssql_num_rows($result1);
  28.  
  29. if ($rows > 0 && $rows1 > 0)
  30. {
  31. //while($row=mssql_fetch_array($result))
  32. for($i=0;$i<$rows;$i++)
  33. {
  34. $row=mssql_fetch_array($result);
  35.  
  36. echo '<table border="0" cellpadding="1" cellspacing="1">';
  37. echo '<tr><td align="left"><b>Airline Name:</b></td><td align="left">'.$row["air_name"].'</td>
  38. <td align="left"><b>Order Date:</b></td><td align="left">'.date("m-d-Y",strtotime($row["order_dt"])).'</td></tr>';
  39. 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>';
  40. echo '<tr><td align="left" valign="top"><b>Shipping Address:</td><td>'.$row["cust_ship_addr1"].'<br/>'.
  41. $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>';
  42. $orderid=$row["order_id"];
  43. echo $orderid;
  44. 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>';
  45.  
  46. for($j=0;$j<$rows1;$j++)
  47. {
  48. $row1=mssql_fetch_array($result1);
  49.  
  50. if ($orderid==$row1["order_id"])
  51. {
  52. echo '<tr><td>'.$row1["order_id"].'</td>';
  53. echo '<td>'.$row1["prod_code"].'</td>';
  54. echo '<td>'.$row1["prod_title"].'</td>';
  55. echo '<td>'.$row1["cate_name"].'</td>';
  56. echo '<td>'.$row1["status"].'</td>';
  57. echo '<td align="right">'.$row1["qty"].'</td>';
  58. echo '<td align="right">'.$row1["vend_price"].'</td>';
  59. $total_vend_amount=$row1["qty"]*$row1["vend_price"];
  60. echo '<td align="right">'.number_format($total_vend_amount,2).'</td>';
  61. echo '<td align="right">'.$row1["sbh_price"].'</td>';
  62. $total_sbh_amount=$row1["qty"]*$row1["sbh_price"];
  63. echo '<td align="right">'.number_format($total_sbh_amount,2).'</td>';
  64. $total_qty+=$row1["qty"];
  65. $total_vend_price+=$total_vend_amount;
  66. $total_sbh_price+=$total_sbh_amount;
  67.  
  68. }
  69. }
  70.  
  71.  
  72. $total_vend_price=number_format($total_vend_price,2);
  73. $total_sbh_price=number_format($total_sbh_price,2);
  74. 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>';
  75. }
  76. 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>';
  77. }
  78. else
  79. {
  80. echo '<table><tr><td align="center"><strong>No results Found</strong></td></tr></table>';
  81. }
  82. }
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
Last edited by cscgal; Sep 27th, 2008 at 8:06 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 15
Reputation: heenix is an unknown quantity at this point 
Solved Threads: 1
heenix heenix is offline Offline
Newbie Poster

Re: PHP table display

 
0
  #2
Sep 27th, 2008
Hi,

I'm not so sure what your actually asking me to help you with here? However, remember that this forum has code tag rules. I'm finding it difficult to separate what your asking us, and what is PHP or SQL.

Also, if possible, could you provide the field types for the data you've shown us?

Thanks,
Christopher Lord.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC