while() loop outputting 1 row when there should be 3+
Posted: Sun Mar 12, 2006 7:46 pm
Hey Hey Ya'll,
I have written a 'confirm shipped' script for a company and even though I KNOW there is more than 1 row that should be returning...
Yet it only returns one...
Code:
SQL Schema:
`Orders`
Invoice_Number
Customer_ID
Date_Ordered
Delivery_date
VAT
Subtotal
month
year
dispatched
`Order_Details`
Invoice_Number
Product_ID
Price
Quantity
Thank You
I have written a 'confirm shipped' script for a company and even though I KNOW there is more than 1 row that should be returning...
Yet it only returns one...
Code:
Code: Select all
<?php
session_start();
session_regenerate_id();
include('connect.php');
if (!$_SESSION['is_admin']){
header("Location: admin_login.php");
die();
}
if ($_GET['orderid']){
$oid=$_GET['orderid'];
}else{
$oid=$_POST['orderid'];
}
if (isset($_POST['submit'])){
if (isset($_POST['Y'])){
$sql=mysql_query("UPDATE Orders SET dispatched='1' WHERE Invoice_Number='$oid'");
echo "Thank You, The Order has Been Confirmed Shipped";
}else{
die('Stopped');
}
}
$get=mysql_query("SELECT p.Name AS name, o.Subtotal AS sub, od.Price AS price, od.Quantity AS quan FROM Products AS p, Order_Details AS od, Orders as o WHERE o.Invoice_Number='$oid' AND o.Invoice_Number=od.Invoice_Number AND od.Product_ID=p.Product_ID") OR DIE (mysql_error());
echo "<table border='.5'>
<tr><td><b>Product</b></td><td><b>Price</b></td><td><b>Quantity</b></td></tr>";
while ($row=mysql_fetch_array($get)){
echo "<tr><td>{$row['name']}</td><td>{$row['price']}</td><td>{$row['quan']}</td></tr>";
}
echo "</table><br />
<form method='POST' action=\"$PHP_SELF\">
<b>Confirm?</b> <b>Yes:</b><input type='checkbox' name='Y'><br /
<b>No:</b><input type='checkbox' name='N'><br />
<input type='submit' name='submit' value='Confirm'>
<input type='hidden' name='orderid' value=\"$oid\"></form><br />
<a href='ManagersMainMenu.php'>Main Menu</a>";
?>`Orders`
Invoice_Number
Customer_ID
Date_Ordered
Delivery_date
VAT
Subtotal
month
year
dispatched
`Order_Details`
Invoice_Number
Product_ID
Price
Quantity
Thank You