Jump to content

problem in counting rows to get the correct qty per item


newphpcoder

Recommended Posts

Hi..I have problem in getting the DemandedQty that was input. Only in the Demanded Qty of P28 items was read.For example I input 21 in Demanded Qty of P28 and then It alerts 21, but when I input 2 in Demanded Qty of P30 the alert was 21. It means only the P28 Demanded Qty was get.here is my code:

<?php																		    error_reporting(0);   date_default_timezone_set("Asia/Singapore"); //set the time zone $con = mysql_connect('localhost', 'root','');if (!$con) {    echo 'failed';    die();}mysql_select_db("mes", $con);?><html><title>Stock Requisition</title><head><link rel="stylesheet" type="text/css" href="kanban.css"><script type="text/javascript">function showSum(element) {  var clickElement = element.value; var click_id = element.id;   var Table = document.getElementById('list'); var rows = Table.rows;    var strSelect = document.getElementById(click_id).value; alert(strSelect); // i tried to alert to check if he gets the correct value, but I found that only the Demanded Qty of P28 was read. And when I try to input on another Demanded Qty like in P30 the alert was blank.  for (var i = 0; i < rows.length; i++) {	 	  var row = rows[i];	        if (row.id.substr(0,3) == strSelect) {       }   }   }</script></head><body><form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><div><table id="list"><thead><th>Items</th><th>Sub Items</th><th>Item Code</th><th>Demanded Qty</th><th>UoM</th><th>Class</th><th>Description</th><th>BIN Location</th></thead><?php$DemandedQty = $_POST['DemandedQty'];$sql = "SELECT DISTINCT Items FROM bom_subitems ORDER BY Items";$res_bom = mysql_query($sql, $con);$rowCounter = 1;while($row = mysql_fetch_assoc($res_bom)){       $Items = $row['Items'];    $Items_ = substr($Items, 12, 3);   echo "<tr>	    <td style='border: none;font-weight: bold;'> <input type='name' value='$Items_' name='Items_[]' id='Items_[$rowCounter]' readonly = 'readonly' style = 'border:none;width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td>	    <td style='border:none;'> </td>	    <td style='border:none;'> </td>	    <td style='border: none;'><center><input type='text' style='text-align: right;' name='DemandedQty[]' id='DemandedQty' value='' size='12' onkeyup ='showSum(this);'></center></td>		    </tr>";			$sql = "SELECT Items, SubItems, ItemCode, UoM, Class, Description, BINLocation, Quantity FROM bom_subitems WHERE Items = '$Items' ORDER BY Items"or die(mysql_error());$res_sub = mysql_query($sql, $con);  $rowCounter = 1; while($row_sub = mysql_fetch_assoc($res_sub)){	 $Items = $row_sub['Items'];	 //$Items_ = substr($Items, 12, 3);	 $SubItems = $row_sub['SubItems'];	 $ItemCode = $row_sub['ItemCode'];	 $UoM = $row_sub['UoM'];	 $Class = $row_sub['Class'];	 $Description = $row_sub['Description'];	 $BINLocation = $row_sub['BINLocation'];	 $Quantity = $row_sub['Quantity'];     echo "<input type='hidden' name='Quantity' id='Quantity' value='$Quantity'>";    echo "<tr>	    <td style='border: none;'> <input type='hidden' value='$Items' id='Items[$rowCounter]' name='Items[]'></td>	    <td style='border: none;'> <input type='text' name='SubItems[]' value='$SubItems' id='SubItems' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td>	    <td style='border: none;'> <input type='text' name='ItemCode[]' value='$ItemCode' id='ItemCode' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td>	    <td style='border: none;'><center><input type='text' name='SubQty[]' id='SubQty[$rowCounter]' value='' size='12' style='border:none;text-align: right;'></center></td>	    <td style='border: none;' size='3'> <input type='text' name='UoM[]' value='$UoM' id='UoM' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='3'></td>	    <td style='border: none;'> <input type='text' name='Class[]' value='$Class' id='Class' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td>	    <td style='border: none;'> <input type='text' name='Description[]' value='$Description' id='Description' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size= '30'></td>	    <td style='border: none;'> <input type='text' name='BINLocation[]' value='$BINLocation' id='BINLocation' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td>		    </tr>";   	 $rowCounter = $rowCounter + 1;}$rowCounter = $rowCounter + 1;}				?></table></div></form></body></html>

Thank you so much

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...