Jump to content

need help in checkbox inside while loop


newphpcoder

Recommended Posts

Hi,

 

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:

 

1. Select SR #

2. After Select SR # data will display below

3. Choose Lot Number

4. Check the beside textbox to subtract/minus the demanded qty to the lot number qty from wms table

5. 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:

 

<?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);
$Date_Shelve =date('Y-m-d H:i:s');
?>
<html>
<title>Picking</title>
<head>
<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;

document.picking_form.action="Picking.php?sr_number="+sr_number;
    document.picking_form.submit();

}
</script>

</head>
<body>
     
<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>

<div id="Picking">
<label class="LLabellot">Select SR # :</label>
<?php          
$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>$items</td>
        <td></td>
        <td style='text-align:right;'>$demandedqty</td>
        <td>$uom</td>
        </tr>";             
        
$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></td>
        <td>$ItemCode</td>
        <td style='text-align:right;'>$SubQty</td>
        <td>$UoM</td>
        <td>$Description</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>
     </tr>";  
    
}       
}
}
  ?>
</div>
</form>
</body>
</html>

 

Thank you so much

post-101569-13482403556125_thumb.jpg

Link to comment
https://forums.phpfreaks.com/topic/263460-need-help-in-checkbox-inside-while-loop/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.