Database question
Posted: Wed Feb 25, 2009 7:20 am
Hello, I have another database question. I am working on a restaurant program, and the person is supposed to input their address, and menu ordered. I have all of that working, but when I run the query to find the ID for the customer, and the ID for their order, it dosent work... Here is my code, I apologize if this isnt alot of information, I will post more later...
The register page collects their Name, Address, Phone
The second page shows their menu, and allows them to type in a quantity for each item
The page to display their information shows their name, phone, and address...
-Then I have a link to "view their menu"
After you click that link, it shows their menu orders... BUT it will work for all of the different customers, other then the last one inputted... Any help is greatly appreciated
CODE for the view customers page
CODE: for the page that displays their info
CODE: for the page to display their ordered menu
-Flightfanatic
The register page collects their Name, Address, Phone
The second page shows their menu, and allows them to type in a quantity for each item
The page to display their information shows their name, phone, and address...
-Then I have a link to "view their menu"
After you click that link, it shows their menu orders... BUT it will work for all of the different customers, other then the last one inputted... Any help is greatly appreciated
CODE for the view customers page
Code: Select all
<?
if (isset($_COOKIE["adminon"])) {
$username="*****";
$password="*****";
$database="*****";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM Orders";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo('<p>');
$a=0;
$i=0;
while ($i < $num) {
$dmCP=mysql_result($result,$i,"ChkPar");
$dmFF=mysql_result($result,$i,"FishFry");
$dmGB=mysql_result($result,$i,"GngBeef");
$dmJS=mysql_result($result,$i,"ShrmpCo");
$dsHF=mysql_result($result,$i,"HotFdg");
$dmWC=mysql_result($result,$i,"ChoCak");
$dmSS=mysql_result($result,$i,"Strwbry");
$dmDX=mysql_result($result,$i,"ChoBrwn");
$a = $dmCP + $a;
$b = $dmFF + $b;
$c = $dmGB + $c;
$d = $dmJS + $d;
$e = $dsHF + $e;
$f = $dmWC + $f;
$g = $dmSS + $g;
$h = $dmDX + $h;
$totCP = $dmCP + $a;
$i++;
}
echo ("This page displays the total number of items ordered<br><br>");
echo "<b>Meal Ordered:</b> <br>Chicken Parmesan: $a <br>Fish Fry: $b <br>Ginger Beef Stir Fry: $c <br>Jumbo Shrimp Cocktail: $d <br>Hot Fudge Sundae: $e <br>Warm Chocolate Cake: $f <br>Strawberry Shortcake: $g <br>Deluxe Über-Chocolate Brownie: $h</br>";
} else {
echo "<b>RESTRICTED AREA</b><br>You must log-in before viewing!";
echo("<br><a href=index.php>Click HERE To Return To Login</a><p>");
}
?>
Code: Select all
<?
if (isset($_COOKIE["adminon"])) {
$username="*****";
$password="*****";
$database="*****";
mysql_connect(localhost,$username,$password);
//@mysql_select_db($database) or die( "Unable to select database");
mysql_select_db($database);
//if (isset($_GET['id'])) $id=$_GET['id'];
$test=$_GET['int'];
//$query="SELECT * FROM Orders WHERE int = $test";
$query = "SELECT * FROM Orders";
$result = mysql_query($query);
//$order = mysql_fetch_object($result);
//$num=mysql_numrows($result);
mysql_close();
echo('<p>');
//$i=0;
//while ($i < $num) {
$inta=mysql_result($result,$i,"int");
//if ($test == $inta) {
$dmCP=mysql_result($result,$i,"ChkPar");
//$dmFF=mysql_result($result,$i,"FishFry");
//$dmGB=mysql_result($result,$i,"GngBeef");
//$dmJS=mysql_result($result,$i,"ShrmpCo");
//$dsHF=mysql_result($result,$i,"HotFdg");
//$dmWC=mysql_result($result,$i,"ChoCak");
//$dmSS=mysql_result($result,$i,"Strwbry");
//$dmDX=mysql_result($result,$i,"ChoBrwn");
while ($order = mysql_fetch_object($result)) {
$dmCP = $order->ChkPar;
$dmFF = $order->GngBeef;
$dmGB = $order->GngBeef;
$dmJS = $order->ShrmpCo;
$dmHF = $order->HotFdg;
$dmWC = $order->ChoCak;
$dmSS = $order->Strwbry;
$dmDX = $order->ChoBrwn;
//echo ($order->int.' ');
if ($order->int == $test){
//echo ("id: $test<br>");
//echo ("inta: $inta<br>");
echo "<b>Meal Ordered:</b> <br>Chicken Parmesian: $dmCP <br>Fish Fry: $dmFF <br>Ginger Beef Stir Fry: $dmGB <br>Jumbo Shrimp Cocktail: $dmJS <br>Hot Fudge Sundae: $dsHF <br>Warm Chocolate Cake: $dmWC <br>Strawberry Short Cake: $dmSS <br>Deluxe Über-Chocolate Brownie: $dmDX</br>";
$i++;
}
//}
//}
}
} else {
echo "<b>RESTRICTED AREA</b><br>You must log-in before viewing!";
echo("<br><a href=index.php>Click HERE To Return To Login</a><p>");
}
//}
?>
-Flightfanatic