Jump to content

while loop only produces 1 record


High_-_Tek

Recommended Posts

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:

[code]
<?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>&nbsp;&nbsp;&nbsp;&nbsp;<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>";

?>
[/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 :)
Link to comment
https://forums.phpfreaks.com/topic/4795-while-loop-only-produces-1-record/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.