By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,917 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,917 IT Pros & Developers. It's quick & easy.

add quantities for system inventory

P: 1
haii........
,first at all sorry because im not good in english
i want to ask how to add quantity for inventory system .this is my form but it has error...
[php]
<?php require_once('Connections/inventory.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
echo $insertSQL = sprintf("UPDATE register set quantity='". $newQuantity ."'
WHERE itemcode='". $_POST['ID'] ."'",
GetSQLValueString($_POST['newQuantity'], "int"));

mysql_select_db($database_inventory, $inventory);
$Result1 = mysql_query($insertSQL, $inventory) or die(mysql_error());

$updateGoTo = "add.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
// header(sprintf("Location: %s", $updateGoTo));
}
mysql_select_db($database_inventory, $inventory);
$query_view = "SELECT * FROM register WHERE register.itemCode= '". $_POST['ID'] ."'";
$view = mysql_query($query_view, $inventory) or die(mysql_error());
$row_view = mysql_fetch_assoc($view);
$totalRows_view = mysql_num_rows($view);
if ($_POST['quantitybaru'])
{
echo $q = "SELECT * FROM register WHERE register.itemcode='". $_POST['ID'] ."'";
$rslt = mysql_query($q);
$curItem = mysql_fetch_array($rslt);
}
$sql = mysql_query("SELECT SUM(quantity) as quantity FROM register WHERE register.itemCode= '". $_POST['ID'] ."'");
while( $row=mysql_fetch_array($sql))
{
$newQuantity = $curItem['quantity'] + $_POST['quantitybaru'];
}
echo "total items= ".$newQuantity ;?>
<script LANGUAGE="JavaScript">
function confirmSubmit()
{
var agree=confirm("Are you sure?");
if (agree)
return true ;
else
return false ;
}
</script>
<!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=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style11 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; }
.style18 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
}
.style19 {font-size: 11px}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="623" border="1" align="center">
<tr>
<td colspan="4"><div align="center" class="style18 style19">ADD ITEM </div></td>
</tr>
<tr>
<td width="93"><span class="style11">Category</span></td>
<td width="154"><span class="style11"><?php echo $row_view['catName']; ?></span></td>
<td width="93"><span class="style11">Invoice No </span></td>
<td width="255" class="style11"><span class="style11">
<label></label>
<?php echo $row_view['invoice_no']; ?></span></td>
</tr>
<tr>
<td><span class="style11">Item Code </span></td>
<td class="style11"><span class="style11">
<label></label>
<?php echo $row_view['itemCode']; ?></span></td>
<td><span class="style11">Add Quantity </span></td>
<td class="style11"><span class="style11">
<label></label>
<label>
<input name="quantitybaru" type="text" class="style11" id="quantitybaru" value=""/>

</label>
Balance :<?php echo $row_view['quantity']; ?></span></td>
</tr>
<tr>
<td><span class="style11">Item</span></td>
<td class="style11"><span class="style11">
<label></label>
<?php echo $row_view['itemName']; ?></span></td>
<td><span class="style11">Price/Unit</span></td>
<td class="style11"><span class="style11">
<label></label>
<?php echo $row_view['price_per_unit']; ?></span></td>
</tr>
<tr>
<td><span class="style11">Supplier</span></td>
<td class="style11"><span class="style11">
<label></label>
<?php echo $row_view['supplier']; ?></span></td>
<td><span class="style11">Date </span></td>

<td class="style11"><span class="style11">
<select name="select3" class="style11">
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
</select>
-&nbsp;
<select name="select" class="style11">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
&nbsp;-&nbsp;
<select name="select2" class="style11">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
</span></td></tr>
<tr>
<td><span class="style11">Address</span></td>
<td class="style11"><span class="style11">
<label></label>
<?php echo $row_view['address']; ?></span></td>
<td><span class="style11">Location</span></td>
<td class="style11"><span class="style11">
<label></label>
<?php echo $row_view['location']; ?></span></td>
</tr>
<tr>
<td><span class="style11">Order No </span></td>
<td class="style11"><span class="style11">
<label></label>
<?php echo $row_view['order_no']; ?></span></td>
<td><span class="style11">Serial Number </span></td>
<td class="style11"><span class="style11">
<label></label>
<?php echo $row_view['serial_no']; ?></span></td>
</tr>
<tr>
<td height="20"><span class="style11">Delievery Order </span></td>
<td class="style11"><span class="style11">
<label></label>
<?php echo $row_view['delivery_order']; ?></span></td>
<td><span class="style11">Staff Name </span></td>
<td class="style11"><span class="style11">
<label></label>
<?php echo $row_view['supervisor']; ?></span></td>
</tr>
</table>
<table width="646" border="0" align="center">
<tr>
<td><label>
<div align="center">
<input name="Submit" type="submit" class="style11" value="ADD ITEM" onClick="return confirmSubmit()" />
<input name="Submit2" type="submit" class="style11" value="CANCEL" />
</div>
</label></td>
</tr>
</table>
<p><label></label>
<label></label>
</p>
<input type="hidden" name="MM_update" value="form1">
</form>

</body>
</html>
<?php
mysql_free_result($view);
?>[/php]
Mar 13 '07 #1
Share this Question
Share on Google+
1 Reply


ronverdonk
Expert 2.5K+
P: 4,258
Welcome to TSDN!

Firstly, before you continue posting, read and follow the Posting Guidelines (top of this forum) and enclose your code within [php] ... [/php ] tags!! As you show it it is absolutely unreadable. And I will not even try to follow 246 lines of unstructured code.

Secondly: you say it "has an error" but that information can be called hardly enough to start looking at it. You need to give more information on your problem, like:

What is the nature of the problem? What have you done to pinpoint the code fragment in which the error occurred? Have you used any debug, echo, trace, etc. to see in what part of your code the error lies?

Ronald :cool:
Mar 13 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.