Hello Fellows… i have this project am working on which i wrote a code to which you can specify the number of input fields you want to use, say 4 then the resulting input fields will be laid out in 4 rows. now the first input in each of the rows is dynamic from mysql database which when you select coca cola, the corresponding input fields against it will display quantity, price and amount from the database… this is working but half way in that when you select an item, the corresponding qty, price and amount will display but when i select a second item on a different row, instead of displaying the corresponding qty, price and amount in the inputs in the present row, it rather updates the first row and displays only amount. i have pasted the code below… can any good developer pls help me out by restructuring this to the desired working condition for me… ur help will be highly appreciated… thanks… Mr.Heart5000
<?php include('../system/config.php'); include('../system/sql.inc.php'); session_start(); $_SESSION["role"] = "acc/staff"; $myname = $_SESSION["username"]; secure($_SESSION["username"]); $catt = ("SELECT * FROM `category` WHERE (`branchcode` = '{$_SESSION["branchcode"]}') AND (`code`=50455)"); // $co = ("select `code` from `category` where $categ= myQ($catt); $proj = myQ("SELECT * FROM `project` WHERE `branchcode` = '{$_SESSION["branchcode"]}'"); $transtype = myQ("SELECT * FROM `transactiontypes`"); $old = $newitem['qtyleft'][$key]; echo $old; $user = myF(myQ("SELECT `fname`,`lname`,`username`, `pass` FROM `staffsales` WHERE (LCASE(`username`) = '$myname');")); if (array_key_exists("Submit",$_POST)){ $transID = check(4); $projectcode = $_POST["pcode"]; $category = $_POST["category"]; $trans_code = $_POST["transtype"]; $admin = "ceo"; $name = $user["fname"]." ".$user["lname"]; $item = $_POST["item"]; $qty = $_POST["qty"]; $unit_price = $_POST["uprice"]; $amount = $_POST["Gtotal"]; $remark = $_POST["rem"]; $approval_status = "pending"; $dotransaction = date('y/m/d h:i'); //$cname = categoryQl($_POST['category'],"category"); foreach ($_POST["item"] as $key => $val) { if (isset($_POST["item"]) && trim($_POST["item"])!= ""){ if(isset($_POST["item"][$key]) && trim($_POST["item"][$key])!= ""){ $qt = $_POST["qty"][$key]; $search = $_POST["item"][$key]; //echo $qtyleft; //echo $qtyleft; //echo $qt; //echo $search; //echo $_POST["item"]; //$newitem = myQ("UPDATE `item` SET qtyleft = $newqty WHERE item_id = '$qtyleft'"); $old = $newitem['qtyleft'][$key]; //echo $old; $sql=myQ("INSERT INTO `store_batch`(`transID`,`projectcode`,`category`, `trans_code`,`trans_done_by`,`approved_by`,`item`, `qty`,`unit_price`,`amount`,`remark`, `approval_status`, `grand_total`, `trans_date`) VALUES( '$transID', '$projectcode', '$category ', '$trans_code ', '$name', '$admin', '".((isset($_POST["item"][$key]) && $_POST["item"][$key] != "") ? $_POST["item"][$key] :"N/A")."', '".((isset($_POST["qty"][$key]) && $_POST["qty"][$key] != "") ? $_POST["qty"][$key] :"N/A")."', '".((isset($_POST["uprice"][$key]) && $_POST["uprice"][$key] != "") ? $_POST["uprice"][$key] :"N/A")."', '".((isset($_POST["amount"][$key]) && $_POST["amount"][$key] != "") ? $_POST["amount"][$key] :"N/A")."', '".((isset($_POST["rem"][$key]) && $_POST["rem"][$key] != "") ? $_POST["rem"][$key] :"N/A")."', '$approval_status', '$amount', '$dotransaction'); ") or die(mysql_error()); $errMsg = ($sql== 1) ? "Application Made Successfully! with Application id = $transID
" : "An error has occured while performing this operation. Please try again later
"; } else $errmsg="Error:please select expense number"; } else $errmsg="Error:please supply a valid input project"; } } ?> Untitled Document body, th, td, p, small { font-size:12px; font-family:Verdana, Arial, Helvetica, sans-serif; margin:0; padding:0; font-style:normal; font-variant:normal; font-weight:normal; line-height: 15px; }