good day, i'm new to programming but i'm eager to learn, i have a problem,
after i submit the number of quantity, the product will add, but then when i search again for another item, the page refresh.. i wanted to output all of the items in sales table so that i could get the grand total.. do i need condition statements for continuos printing in the sales table after selecting an item? do i need to separate the sales page,but i want it on a same page? do i need to store it in an array and output?,, please help me,where to start next, or my code sucks,do it all over again??? :(
<title> SALES </title>
<body>
<form action="index.php" method="post">
ENTER ID: <input type="text" name="item" />
<input type="submit" name="submit" value="submit"/>
<input type="submit" name="refresh" value="refresh" meta http-equiv="refresh" />
</form>
<?php
include("connection.php");
if(isset($_POST['submit'])){
$sel_item = $_POST['item'];
$query = "SELECT * FROM items where {$sel_item} = id";
$result = mysql_query($query) or die();
echo "<table>";
echo "<tr><th>ID</th> <th>ITEM NAME</th> <th>DESCRIPTION</th> <th>SIZE</th> <th>COLOR</th> <th style='text-align:right'>PRICE</th> <th style='text-align:right'>QUANTITY</th></tr>";
while($row = mysql_fetch_array($result)) {
echo"<tr><td>";
echo $row['id'];
echo"</td><td>";
echo $row['item_name'];
echo"</td><td>";
echo $row['description'];
echo"</td><td>";
echo $row['size'];
echo"</td><td>";
echo $row['color'];
echo"</td><td style='text-align:right'>";
echo "P".$row['price'];
echo"</td><td style='text-align:right'>";
echo $row['quantity'];
echo "</td><td>";
}
echo "</table>";
}
?>
<br/><br/>
<h1>SALES</h1>
<form action="index.php" method="post">
<table width="400">
<tr>
<td> ID: <strong><?php echo $sel_item ?></td>
</tr>
<tr>
<td> QUANTITY: </td><td><input type="text" name="quantity"/></td>
<td> <input type="submit" name="add" value="add" ></td>
</tr>
<?php
include("connection.php");
$total=0;
if(isset($_POST['add'])){
$selc_item = $_POST['selc_item'];
$item_quantity = $_POST['quantity'];
$query = "SELECT * FROM items where {$item_quantity} <= quantity ";
$result = mysql_query($query) or die();
echo"<table>";
echo"<tr>";
echo"<th>ID</th><th>ITEM NAME</th><th>QUANTITY</th><th>PRICE</th><th>TOTAL PRICE</th><th></th></tr>";
while($row = mysql_fetch_array($result)){
$item_name = $row[1];
$item_price = $row[5];
$t_item_price = $row[5] * $item_quantity;
}
echo"<tr>";
echo"<td>{$selc_item}</td>";
echo"<td>{$item_name}</td>";
echo"<td>{$item_quantity}</td>";
echo"<td>{$item_price}</td>";
echo"<td>{$t_item_price}</td>";
echo"</tr><br />";
echo"</table>";
}
?>
</form>
</html>