add quantities for system inventory

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • starcandy
    New Member
    • Mar 2007
    • 1

    add quantities for system inventory

    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('C onnections/inventory.php') ; ?>
    <?php
    function GetSQLValueStri ng($theValue, $theType, $theDefinedValu e = "", $theNotDefinedV alue = "")
    {
    $theValue = (!get_magic_quo tes_gpc()) ? addslashes($the Value) : $theValue;

    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValu e) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? "'" . doubleval($theV alue) . "'" : "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValu e : $theNotDefinedV alue;
    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'] ."'",
    GetSQLValueStri ng($_POST['newQuantity'], "int"));

    mysql_select_db ($database_inve ntory, $inventory);
    $Result1 = mysql_query($in sertSQL, $inventory) or die(mysql_error ());

    $updateGoTo = "add.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($update GoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
    }
    // header(sprintf( "Location: %s", $updateGoTo));
    }
    mysql_select_db ($database_inve ntory, $inventory);
    $query_view = "SELECT * FROM register WHERE register.itemCo de= '". $_POST['ID'] ."'";
    $view = mysql_query($qu ery_view, $inventory) or die(mysql_error ());
    $row_view = mysql_fetch_ass oc($view);
    $totalRows_view = mysql_num_rows( $view);
    if ($_POST['quantitybaru'])
    {
    echo $q = "SELECT * FROM register WHERE register.itemco de='". $_POST['ID'] ."'";
    $rslt = mysql_query($q) ;
    $curItem = mysql_fetch_arr ay($rslt);
    }
    $sql = mysql_query("SE LECT SUM(quantity) as quantity FROM register WHERE register.itemCo de= '". $_POST['ID'] ."'");
    while( $row=mysql_fetc h_array($sql))
    {
    $newQuantity = $curItem['quantity'] + $_POST['quantitybaru'];
    }
    echo "total items= ".$newQuant ity ;?>
    <script LANGUAGE="JavaS cript">
    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.dt d">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitl ed 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"><di v align="center" class="style18 style19">ADD ITEM </div></td>
    </tr>
    <tr>
    <td width="93"><spa n class="style11" >Category</span></td>
    <td width="154"><sp an class="style11" ><?php echo $row_view['catName']; ?></span></td>
    <td width="93"><spa n 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="quantityb aru" type="text" class="style11" id="quantitybar u" 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">20 07</option>
    <option value="2008">20 08</option>
    <option value="2009">20 09</option>
    <option value="2010">20 10</option>
    <option value="2011">20 11</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"><sp an 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_resu lt($view);
    ?>[/php]
    Last edited by ronverdonk; Mar 13 '07, 12:12 PM. Reason: code within tags
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    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:

    Comment

    Working...