Thread: Resolved My SQL Database PHP Inquiry
View Single Post
Old 12-06-2012, 01:33 AM   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
Exclamation My SQL Database PHP Inquiry

This is the statement I have tested in PhpMyAdmin and it works:
Code:
SELECT customers.CompanyName, orders.CustomerID, orders.OrderID, order_details.OrderID, order_details.ProductID, products.ProductID, products.ProductName, products.UnitPrice, products.UnitsInStock, orders.shipVia, shippers.shipperId, shippers.CompanyName, orders.Freight
FROM customers, orders, order_details, products, shippers
WHERE customers.CompanyName = "Around"
AND customers.CustomerID = orders.CustomerID
AND orders.OrderID = '10308'
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
What I want to do it have my php file pull information from the results into a table. I already have my config files and everything set up. I just need help with getting this stuff into a table. I have never really been good at doing the tables, the forms are easy.

Here is my php code from one of my files that leads to this file. If you can please help me rewrite it with a table:

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



<form name='customer' method='get' action='order_details.php' >
<p>Below are the order numbers for this customer: </p><select name='customer'>
<?php
	$sql = "SELECT customers.CompanyName, customers.CustomerID, orders.OrderID
		FROM customers, orders
		WHERE customers.CompanyName LIKE '" . $_GET['customer'] . "%'
		AND customers.CustomerID LIKE orders.CustomerID;";
	
	$result = mysql_query($sql) or die(mysql_error());
	
		while ($row = mysql_fetch_assoc($result))
		{
			echo '<option value =' .  $row['OrderID'] . '>' . $row['OrderID'] . '</option>';
		}
		
?>

</select>
&nbsp;<input type='submit' name='submit' />

</form>

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

?>
The table needs to show product name, quantity, unit price, shipper, shipping cost(freight), and total cost of order.

Last edited by logepoge1; 12-06-2012 at 09:12 PM..
logepoge1 is offline   Reply With Quote