newphpcoder Posted June 4, 2012 Share Posted June 4, 2012 Hi.. I have form for picking and now I got encountered problem in getting the value of lot_number where in select option: 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"> </head> <body> <form name='picking_form' action='' method='post'> <?php $Approved = isset($_POST['priority']); if ($Approved) { $lot_number = $_POST['lot_number']; $sr_number_ = $_POST['sr_number_']; $SubQty = $_POST['SubQty']; $ItemCode = $_POST['ItemCode']; $picked_by = $_POST['picked_by']; $sql = "SELECT stock_item, qty FROM wms WHERE stock_item = '$ItemCode' AND lot_number = '$lot_number'"; $res = mysql_query($sql, $con) or die(mysql_error()); $row = mysql_fetch_assoc($res); $stock_item = $row['stock_item']; $qty = $row['qty']; if($qty >= $SubQty){ $output = $qty - $SubQty; $qty_withdraw = '0.00'; } else{ $output = '0.00'; $qty_withdraw = $SubQty - $qty; } echo "<br/><br/><br/>"; echo $lot_number; echo $sr_number_; echo $picked_by; echo $output; echo $qty_withdraw; } ?> <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)){ echo "<form name='picking_lotnum' action='' method='post'>"; $sr_number_ = $row_sr_main['sr_number']; $items = $row_sr_main['Items']; $demandedqty = $row_sr_main['DemandedQty']; $uom = $row_sr_main['uom']; echo "<label> SR # :</label>"; echo "<input type='text' readonly='readonly' style='border:none;' id='sr_number_' name='sr_number_' value='$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> Picked By </th> <th> Approved</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) AND stock_item = '$ItemCode' ORDER BY lot_number"; $rows = mysql_query($query, $con); echo "<tr> <td></td> <td id='ItemCode'>$ItemCode</td> <td style='text-align:right;' id='SubQty'>$SubQty</td> <td>$UoM</td> <td>$Description</td>"; echo "<td id='lot_number'><select name = 'lot_number' id='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>"; echo "<td> <input type='text' name='picked_by' id='picked_by' size='20' value=''> </td>"; echo "<td><input type='submit' name='priority' value='Approved' id='priority'></td>"; echo "</tr>"; } } echo "</form>"; } echo "</table>"; echo "</form>"; echo "</div>"; ?> </body> </html> when I echo the $lot_number: the result is Select. it did not get the data selected. Thank you... Link to comment https://forums.phpfreaks.com/topic/263611-need-help-in-getting-the-select-option-value-after-click-the-submit-button/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.