Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Need Help In Checkboxes Inside While Loop

align loop

  • Please log in to reply
1 reply to this topic

#1 newphpcoder


    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 527 posts

Posted 31 May 2012 - 07:55 PM


I created picking module and now I need help in subtract/minus Demanded Qty to the Qty from the wms table based on the lot number selected and it will happen only when the checkbox was check.

Here is the flow:
  • Select SR #
  • After Select SR # data will display below
  • Choose Lot Number
  • Check the beside textbox to subtract/minus the demanded qty to the lot number qty from wms table
  • When the check box was check and after subtract the select option will be only display the lot number you selected.

I am new in using checkbox.

Here is my code:

   date_default_timezone_set("Asia/Singapore"); //set the time zone 
$con = mysql_connect('localhost', 'root','');

if (!$con) {
    echo 'failed';

mysql_select_db("mes", $con);
$Date_Shelve =date('Y-m-d H:i:s');
<link href="kanban.css" rel="stylesheet" type="text/css">

<script type="text/javascript">
function get_option(elm){
  var elm = document.getElementById('sr_number');
sr_number = elm.options[elm.selectedIndex].value;



<div id="SR_date">
<label>Date :</label>
<input type="text" name="date_pick" value="<?php echo $Date_Shelve; ?>" size="16" readonly="readonly" style="border: none;">   

 <div id="Picking">
<label class="LLabellot">Select SR # :</label>
$query = "SELECT DISTINCT m.sr_number FROM sr_main m JOIN sr_submain s ON (m.sr_number = s.sr_number)  ORDER BY sr_number";				
$rows = mysql_query($query, $con);	   
 echo "<select name = 'sr_number' onchange='get_option();'>";		   	 
  echo "<option> Select </option>";
  while ($record = mysql_fetch_array($rows))		 
	  echo "<option value = '{$record['sr_number']}'";			
	  if ($lot_number == $record['sr_number'])				
	  echo "selected = 'selected'";			
	   echo ">{$record['sr_number']}</option>";	   
  echo "</select>";   
  echo "<br/><br/>";	

  $sr_number = $_POST['sr_number'];

$sql = "SELECT sr_number, Items, DemandedQty, uom
FROM sr_main WHERE sr_number = '$sr_number'";
$res_sr_main = mysql_query($sql, $con);

$row_num = mysql_num_rows($res_sr_main);

if($row_num > 0){

while($row_sr_main = mysql_fetch_assoc($res_sr_main)){

$sr_number = $row_sr_main['sr_number'];
$items = $row_sr_main['Items'];
$demandedqty = $row_sr_main['DemandedQty'];
$uom = $row_sr_main['uom'];
echo "<form name='picking_form' action='' method='post'> ";  
echo "<label> SR # :</label>";
echo $sr_number;

echo "<table>";
echo "<th>Items</th>
  	  <th> Item Code </th>
	    <th> Demanded Qty </th>
	    <th> UoM </th>
	    <th> Description </th>
	    <th> Lot Number </th>
	    <th> Approve</th>";
echo "<tr>
	    <td style='text-align:right;'>$demandedqty</td>
$sql_sub = "SELECT sr_number, Items, ItemCode, SubQty, UoM, Description
FROM sr_submain WHERE sr_number = '$sr_number' and Items = '$items'";
$res_sub = mysql_query($sql_sub, $con);

while($row_sub = mysql_fetch_assoc($res_sub)){
  $sr_num = $row_sub['sr_number'];
  $Items = $row_sub['Items'];
  $ItemCode = $row_sub['ItemCode'];
  $SubQty = $row_sub['SubQty'];
  $UoM = $row_sub['UoM'];
  $Description = $row_sub['Description'];

$query = "SELECT lot_number from wms WHERE (date_shelve IS NOT NULL) ORDER BY lot_number";				
$rows = mysql_query($query, $con); 
 echo "<tr>
	    <td style='text-align:right;'>$SubQty</td>
 echo "<td><select name = 'lot_number'>";
 echo "<option> Select </option>";			   
  while ($record = mysql_fetch_array($rows))	      
	  echo "<option value = '{$record['lot_number']}'";			
	  if ($lot_number == $record['lot_number'])				
	  echo "selected = 'selected'";			
	   echo ">{$record['lot_number']}</option>";	    
  echo "</select>";   
	 echo "<td><input type='checkbox' name='chk' value=''></td>


Thank you so much

Attached Thumbnails

  • picking.JPG

  • 0

#2 BlackRabbit


    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts
  • Location:Argentina
  • Programming Language:C, C++, C#, PHP, JavaScript, Transact-SQL, Bash, Others
  • Learning:Java, Others

Posted 03 June 2012 - 11:24 AM

i don't think i understand the problem here
  • 0

Also tagged with one or more of these keywords: align, loop

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download