| | |
PHP table display
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2008
Posts: 18
Reputation:
Solved Threads: 1
PHP Syntax (Toggle Plain Text)
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
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?
PHP Syntax (Toggle Plain Text)
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)
php Syntax (Toggle Plain Text)
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>'; } }
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
•
•
Join Date: Sep 2008
Posts: 15
Reputation:
Solved Threads: 1
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.
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.
![]() |
Similar Threads
- Open In New Window Php (PHP)
- php table help (PHP)
- Easy Qu - Getting data with PHP (PHP)
- php counter (PHP)
- PHP question regarding Forms (PHP)
- Displaying RSS feed on web site using rss2html.php (PHP)
- Hello Help I'm Wired PhP (PHP)
- new to php, need help adding a forum (PHP)
- php wont submit data into the database (PHP)
Other Threads in the PHP Forum
- Previous Thread: passing sessions between pages
- Next Thread: Php development approach
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube





