Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-06-2012, 08:34 PM   PM User | #1
logepoge1
New Coder

 
Join Date: Oct 2012
Posts: 44
Thanks: 3
Thanked 0 Times in 0 Posts
logepoge1 is an unknown quantity at this point
Problems with PHP Adding Rows/Columns

Code:
<?php
	require('includes/header.php');
	
?>

<h4> <ul id="menu">
<li><p><a href="customer_details.php">Customer Details</a></p></li>
<li><p><a href="order_customer_details.php">Details by order</a></p></li>
<li><p><a href="country_list.php">Customers by Country</a></p></li>
<li><p><a href="categories.php">Products by category</a></p></li>
<li><p><a href="low_stock.php">Low Stock Items</a></p></li>
<li><p><a href="index.php">Home</a></p></li>
</ul></h4>


<?php
	$sql = "SELECT customers.CompanyName, orders.CustomerID, orders.OrderID, order_details.OrderID, order_details.ProductID, products.ProductID, products.ProductName, order_details.UnitPrice, order_details.Quantity, orders.shipVia, shippers.shipperId, shippers.CompanyName, orders.Freight
	FROM customers, orders, order_details, products, shippers
	WHERE customers.CustomerID = orders.CustomerID
	AND orders.OrderID = '" . $_GET['order'] . "%'
	AND orders.OrderID = order_details.OrderID
	AND order_details.ProductID = products.productID
	AND orders.ShipVia = shippers.ShipperID
	ORDER BY products.productName, products.UnitsInStock, products.UnitPrice, shippers.CompanyName, orders.Freight";
	
	$result = mysql_query($sql) or die(mysql_error());

	
echo "<table border='1'>
<tr>
<th>Product Name</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Shipper</th>
<th>Shipping Cost</th>
<th>Total Cost</th>
</tr>";
while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['ProductName'] . "</td>";
  echo "<td>" . $row['Quantity'] . "</td>";
  echo "<td>" . $row['UnitPrice'] . "</td>";
  echo "<td>" . $row['CompanyName'] . "</td>";
  echo "<td>" . $row['Freight'] . "</td>";
  //echo "<td>""</td>";
  }
echo "</table>";
		
?>



<?php
require('includes/footer.php'); 

?>
I want to multiply the quantity row by the cost row and add the Freight amount to it. Please help.
logepoge1 is offline   Reply With Quote
Old 12-07-2012, 01:03 AM   PM User | #2
logepoge1
New Coder

 
Join Date: Oct 2012
Posts: 44
Thanks: 3
Thanked 0 Times in 0 Posts
logepoge1 is an unknown quantity at this point
How can I do that math?
logepoge1 is offline   Reply With Quote
Old 12-07-2012, 01:31 AM   PM User | #3
Custard7A
Regular Coder

 
Custard7A's Avatar
 
Join Date: Jul 2010
Location: Australia
Posts: 269
Thanks: 32
Thanked 32 Times in 32 Posts
Custard7A is an unknown quantity at this point
PHP Code:


$total 
$row['Quantity'] * $row['UnitPrice'] + $row['Freight']; 
Custard7A is offline   Reply With Quote
Reply

Bookmarks

Tags
php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:04 AM.


Advertisement
Log in to turn off these ads.