Jump to content

Ordering system


alan6566

Recommended Posts

Hi, i have been thinking on ways to make an ordering system for my web site.

 

The code bellow shows how i populate the page. i desplay the pizza's from the data base. i want at the end of each line a box thati allows the user to pick howmany pizzas they want. from they when they click order i want it to send all the information of what they want so they can double check it and when they click the final order button it will send to a diffrent order table.

 

<? 
session_start();

if ($_SESSION['userName'])

{}

else
{
header('location:../index.php');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Deliver-Pizza Topping</title>
<link href="css/pizza-topping.css"  rel="stylesheet" type="text/css" />

</head>

<body>

<div id="container">

     <div id="header">
    <img src="images/logo.jpg" alt="logo" />
        
        <a href="log-off.php" id="logg-off" >log off</a>
        
    <ul id="nav">
    <li><a href="home.php" target="_self">Home</a></li> <span> | </span>
    <li><a href="Pizza-Topping.php" target="_self">Pizza Topping</a></li> <span> | </span>
    <li><a href="order.php" target="_self">Order</a></li> <span> | </span>
        <li><a href="Account.php" target="_self">Account Details</a></li> <span> | </span> 
       </ul> 
</div>
   
<div id="Featured">
<img src="images/banner1.jpg" alt="banner" name="banner"" ID="banner"></div><!--end Featured-->
<div class="featuredimage" id="main">
<div id="content" class="tiles">
    <h1>Pizza-Topping</h1><hr />
    <p>Please select the pizza you would like bellow</p>
    
    <div id ="staff"><div style="width:970px; height:300px; overflow:auto"

<left> <table>
<tr>
<th>Type</th>
<th>Size</th>
<th>Topping</th>
<th>Cost</th>
<th>Information</th>
<th>Order</th>
</tr>
<tr>
<form name="input" action="order.php" method="post">
<?php


mysql_connect("localhost", "root", "")or die("cannot connect"); 
    mysql_select_db("deliverpizza")or die("cannot select DB");

$sql="SELECT * FROM `pizzatopping` ";
$result= mysql_query($sql);	

while($row =mysql_fetch_assoc($result)) {

?>

<td><?php echo $row['type'] ?></td>
<td><?php echo $row['size'] ?></td>
<td><?php echo $row['topping'] ?></td>
<td><?php echo $row['cost'] ?></td>
<td><?php echo $row['info'] ?></td>
<td>


<input type:"text" name:"pizza<?php echo $row['id'] ?>" /></td>


</tr></left>
<?php
}
?>
<input type="submit" value="Order" />
</table>
</div>
</div>
    
</div>
</div>
<!--end content-->

<div id="footer"><span><p>Created By Ryan Williams</p></span></div><!--end footer-->
</div><!--end container-->




</body>
</html>

 

Help please

Link to comment
https://forums.phpfreaks.com/topic/259496-ordering-system/
Share on other sites

See if this gets you going.

<?php
session_start();

mysql_connect("localhost", "root", "")or die("cannot connect"); 
    mysql_select_db("deliverpizza")or die("cannot select DB");

if (isset($_SESSION['userName'])){
}else{
header('location:../index.php');
exit;
}
if (isset($_POST['place_order'])){
foreach ($_POST['quantity'] as $k => $qnt){
	if ($qnt>0){
	//Do what you want with results.  I'll echo here.
	echo "Pizza ID: {$_POST['pizza'][$k]}<br />";
	echo "Quantity: $qnt<br />";
	}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Deliver-Pizza Topping</title>
<link href="css/pizza-topping.css"  rel="stylesheet" type="text/css" />

</head>
<body>
<div id="container">
<div id="header">
    <img src="images/logo.jpg" alt="logo" />
    <a href="log-off.php" id="logg-off" >log off</a>
   <ul id="nav">
    <li><a href="home.php" target="_self">Home</a>  |  </li>
	<li><a href="Pizza-Topping.php" target="_self">Pizza Topping</a>  |  </li>
	<li><a href="order.php" target="_self">Order</a>  |  </li>
	<li><a href="Account.php" target="_self">Account Details</a>  |   </li>
</ul> 
</div>
   
<div id="Featured">
<img src="images/banner1.jpg" alt="banner" name="banner" ID="banner" /></div><!--end Featured-->
<div class="featuredimage" id="main">
<div id="content" class="tiles">
    <h1>Pizza-Topping</h1><hr />
    <p>Please select the pizza you would like bellow</p>
    
    <div id ="staff"><div style="width:970px; height:300px; overflow:auto">
<form name="input" action="order.php" method="post">
<table>
<tr>
	<th>Type</th>
	<th>Size</th>
	<th>Topping</th>
	<th>Cost</th>
	<th>Information</th>
	<th>Order</th>
</tr>
<?php
$sql="SELECT * FROM `pizzatopping` ";
$result= mysql_query($sql);	
while($row =mysql_fetch_array($result)) {
?>
<tr>
	<td><?php echo $row['type'] ?></td>
	<td><?php echo $row['size'] ?></td>
	<td><?php echo $row['topping'] ?></td>
	<td><?php echo $row['cost'] ?></td>
	<td><?php echo $row['info'] ?></td>
	<td><input type="hidden" name="pizza[]" value="<?php echo $row['id'] ?>" />
	<?php
	echo "<select name=\"quantity[]\">\r";
	foreach (range(0,10) as $q){
	echo  "<option value=\"$q\">$q</option>\r";
	}
	echo "</select>\r";
	?>
	</td>
</tr>
<?php
}
?>
<tr>
	<td colspan="6"><input type="submit" name="place_order" value="Order" /></td>
</tr>
</table>
</form>
</div>
</div>
    
</div>
</div>
<!--end content-->
<div id="footer"><p>Created By Ryan Williams</p></div><!--end footer-->
</div><!--end container--> 
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/259496-ordering-system/#findComment-1330262
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.