Home > Net >  Multiple values keep in database
Multiple values keep in database

Time:11-16

I want to keep selected multiple values into database like 3,4. Right now, the problem is, if I choose 2 values from dropdown and try to insert into database, it inserted as two rows like 3 for 1 row and 4 for 1 row. Is there anyway to keep it as like 3,4 into database? In Javascript, I made the alert and checked the values. It showed as 3,4 if i choose. But when I try to insert into database, it just inserted as two rows. I also added explode to save with , in database but it didnt't work either.

<label  for="affectedwaferid" style="margin-left: 1px;">Affected Wafer ID : <span id="selected-result"></span></label>
       <div >
        <p  style="margin-top: -6px;">
            
            <select  id="affectedwaferid" name="affectedwaferid" multiple>
            <option value="" selected > Select Quantity</option>
            <?php  
            //echo $cbo_oorigsite;
            ?>
            <option value="1">1</option>
              <option value="2">2</option>
              <option value="3">3</option>
              <option value="4">4</option>
              <option value="5">5</option>
              <option value="6">6</option>
              <option value="7">7</option>
              <option value="8">8</option>
              <option value="9">9</option>
              <option value="10">10</option>
              <option value="11">11</option>
              <option value="12">12</option>
              <option value="13">13</option>
              <option value="14">14</option>
              <option value="15">15</option>
              <option value="16">16</option>
              <option value="17">17</option>
              <option value="18">18</option>
              <option value="19">19</option>
              <option value="20">20</option>
              <option value="21">21</option>
              <option value="22">22</option>
              <option value="23">23</option>
              <option value="24">24</option>
              <option value="25">25</option>

          </select>
        </p>
      </div>
  <div ></div></div>

    <?php  
// ini_set("memory_limit","512M");
include("_dbconn.php");
include("//sgewsnant21.amk.st.com/ewsweb/wwwroot/library/common7/db_config.inc");
include("//sgewsnant21.amk.st.com/ewsweb/wwwroot/library/common7/standard_defines.inc");
session_start();

$refno = isset ($_GET['refno'])? $_GET['refno']:'';
$problemdatetime = isset ($_GET['probdect'])? $_GET['probdect']:'';
$reportedby = isset ($_GET['rptdby'])? $_GET['rptdby']:'';
$lotnum = isset ($_GET['lnum'])? $_GET['lnum']:'';
$device = isset ($_GET['device'])? $_GET['device']:'';
$pnl = isset ($_GET['pnl'])? $_GET['pnl']:'';
$dept = isset ($_GET['dept'])? $_GET['dept']:'';
$affected_qty = isset ($_GET['site'])? $_GET['site']:'';
$affected_waferid = isset ($_GET['affectedwf'])? $_GET['affectedwf']:'';
$physical_qty = isset ($_GET['psyqty'])? $_GET['psyqty']:'';
$waferchip_qty = isset ($_GET['lblwafer'])? $_GET['lblwafer']:'';
$wafercrack_qty = isset ($_GET['wfcrack'])? $_GET['wfcrack']:'';
$defect_type = isset ($_GET['values'])? $_GET['values']:'';
$prob_detectstep = isset ($_GET['dectprocess'])? $_GET['dectprocess']:'';
$affected_area = isset ($_GET['affctarea'])? $_GET['affctarea']:'';
$pack_type = isset ($_GET['ptype'])? $_GET['ptype']:'';
$packingseal = isset ($_GET['pk'])? $_GET['pk']:'';
$packing_damage = isset ($_GET['pkdmg'])? $_GET['pkdmg']:'';
$pink_foam = isset ($_GET['canis'])? $_GET['canis']:'';
$esd_bag = isset ($_GET['celidst'])? $_GET['celidst']:'';
$label_wafertxt = isset ($_GET['labelwafertxt'])? $_GET['labelwafertxt']:'';
$wafer_qty = isset ($_GET['wfqty'])? $_GET['wfqty']:'';
$barvalue = isset ($_GET['barvalue'])? $_GET['barvalue']:'';
$barvaluetwo = isset ($_GET['barvaluetwo'])? $_GET['barvaluetwo']:'';
$edge_wafer = isset ($_GET['fileToUpload3'])? $_GET['fileToUpload3']:'';
$packing_list = isset ($_GET['fileToUpload4'])? $_GET['fileToUpload4']:'';
$other_txt = isset ($_GET['othtxt'])? $_GET['othtxt']:'';


$barcodeArray = explode(",",$affected_waferid);
    foreach($barcodeArray as $value){
    $affected_waferid = $value;
    $sql1 = "INSERT INTO lot_track_smd.tbl_visualdefect_report (refno, problemdatetime, reportedby, lotnum, device, pnl, dept, waferchip_qty, wafercrack_qty, affected_qty, affected_waferid, physical_qty, prob_detectstep, affected_area, pack_type, defect_type, packingseal, packing_damage, pink_foam, esd_bag, wafer_qty, label_wafertxt, other_txt, waferid_defect, local_defect, edge_wafer, packing_list) 
    VALUES ('$refno','$problemdatetime','$reportedby','$lotnum','$device','$pnl','$dept','$waferchip_qty','$wafercrack_qty','$affected_qty','$affected_waferid','$physical_qty','$prob_detectstep','$affected_area','$pack_type','$defect_type','$packingseal','$packing_damage','$pink_foam','$esd_bag','$wafer_qty','$label_wafertxt','$other_txt', '$barvalue', '$barvaluetwo', '$edge_wafer', '$packing_list')";
        $result1 = mysqli_query($conn,$sql1);
    }
flush();
mysqli_close($conn);
?>

CodePudding user response:

Remove your foreach loop and explode function , others still can remain same

Your original code

$barcodeArray = explode(",",$affected_waferid); // remove
    foreach($barcodeArray as $value){ // remove
    $affected_waferid = $value; // remove
    $sql1 = "INSERT INTO lot_track_smd.tbl_visualdefect_report (refno, problemdatetime, reportedby, lotnum, device, pnl, dept, waferchip_qty, wafercrack_qty, affected_qty, affected_waferid, physical_qty, prob_detectstep, affected_area, pack_type, defect_type, packingseal, packing_damage, pink_foam, esd_bag, wafer_qty, label_wafertxt, other_txt, waferid_defect, local_defect, edge_wafer, packing_list) 
    VALUES ('$refno','$problemdatetime','$reportedby','$lotnum','$device','$pnl','$dept','$waferchip_qty','$wafercrack_qty','$affected_qty','$affected_waferid','$physical_qty','$prob_detectstep','$affected_area','$pack_type','$defect_type','$packingseal','$packing_damage','$pink_foam','$esd_bag','$wafer_qty','$label_wafertxt','$other_txt', '$barvalue', '$barvaluetwo', '$edge_wafer', '$packing_list')";
        $result1 = mysqli_query($conn,$sql1);
    } // remove
flush();
mysqli_close($conn);

To this

$sql1 = "INSERT INTO lot_track_smd.tbl_visualdefect_report (refno, problemdatetime, reportedby, lotnum, device, pnl, dept, waferchip_qty, wafercrack_qty, affected_qty, affected_waferid, physical_qty, prob_detectstep, affected_area, pack_type, defect_type, packingseal, packing_damage, pink_foam, esd_bag, wafer_qty, label_wafertxt, other_txt, waferid_defect, local_defect, edge_wafer, packing_list) 
        VALUES ('$refno','$problemdatetime','$reportedby','$lotnum','$device','$pnl','$dept','$waferchip_qty','$wafercrack_qty','$affected_qty','$affected_waferid','$physical_qty','$prob_detectstep','$affected_area','$pack_type','$defect_type','$packingseal','$packing_damage','$pink_foam','$esd_bag','$wafer_qty','$label_wafertxt','$other_txt', '$barvalue', '$barvaluetwo', '$edge_wafer', '$packing_list')";
$result1 = mysqli_query($conn,$sql1)

flush();
mysqli_close($conn);
  • Related