ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์ProgrammingPHP select multiple เช็คค่าไม่ให้แอดค่าเดิมซ้ำ ขอวิธีหน่อยครับ ขอบคุณครับ
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: PHP select multiple เช็คค่าไม่ให้แอดค่าเดิมซ้ำ ขอวิธีหน่อยครับ ขอบคุณครับ  (อ่าน 714 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
thammaratr
Newbie
*

พลังน้ำใจ: 0
ออฟไลน์ ออฟไลน์

กระทู้: 1



ดูรายละเอียด
« เมื่อ: 08 มิถุนายน 2017, 11:01:32 »

https://www.img.in.th/image/fdcT



ทำไงถึงจะเช็คค่าไม่ให้แอดซ้ำกันครับ ขอตัวอย่างหน่อยครับ เพราะมันจะมีกรณีที่แอดไปแล้ว กดเซฟแล้ว ถ้าจะมาแก้ไขอีกทีอ่าครับ มันก้จะสามารถแอดค่าเดิมได้ รอบแรกข้อมูลด้านซ้ายจะเลือกซ้ำไม่ได้เพราะมันดึงไปด้านขวาแล้ว แต่พอจะมาแก้ไข ข้อมูลด้านซ้ายก้จะกลับมาครบเหมือนเดิมเพราะคิวรี่มาจากdb (งงไหมครับ)
ขอบคุณครับ
โค๊ด:
$stmt = "SELECT data_entry1.operation,operation_map.description,data_entry1.attribute_Code,attribute_map.description as attribute_map_description,param2  
FROM data_entry1,attribute_map,operation_map
WHERE data_entry1.operation=operation_map.operation and
data_entry1.attribute_code=attribute_map.attribute_code and
param1 in ('st_validate_partno_with_bom','st_validate_IQR_with_bom_by_serialno')  and data_entry1.attribute_Code=". $strattributeID  ;
$params = array($strattributeID);
$objQuery = mssql_query($stmt) or die ("Error Query [".$stmt."]");
$result = mssql_fetch_array($objQuery);
?>
<form action="save.php" id="myform" name="myform" method="post" >
<div class="row">
<div class="col-md-12 col-sm-12 col-lg-12">
<table  border="1" class="table table-striped custab" style="width: 100%;"">
<tr>
<th>Operation Name</th>
<td><input type="hidden" name="Operation Name" value="<?php echo $result["description"];?>"><?php echo $result["description"];?></td>
</tr>
<tr>
<th width="80">attribute_Code</th>
<td><input type="hidden" name="txtattribute_Code" value="<?php echo $result["attribute_Code"];?>"><?php echo $result["attribute_Code"];?></td>
</tr>
</table>
</div>
</div>
<div class="container-fluid">
  <div class="row">
    <div class="col-md-5 col-sm-5 col-lg-5" style="position:relative; left:-35px;">
     <label class="control-label">Bom name</label>
<?php
$sql="SELECT  distinct child_item_desc 
from bom_master"
;
$dbquery =mssql_query($sql);
?>

<select multiple class="form-control" id="StaffList" style="width: 110%; height: 350px;">
<?php
while($rw mssql_fetch_array($dbquery)){?>

<option value="<?=$rw['child_item_desc']?>"><?=$rw['child_item_desc']?></option>
<?php
}?>

</select>
    </div>
    <div class="col-md-2 col-sm-2 col-lg-2">
     <div class="add-btns" style="width: 100%;position:relative; left:-13px;">
<br>
<br>
<br>
<input type="button" id="btnAvenger" value=">>>" class="btn btn-primary" />
<input type="button" id="btnAvengers" value="<<<" class="btn btn-primary" />
<input type="button" value="Delete" class="btn btn-danger" id="btnRemoveAvenger" />
</div>
    </div>
    <div class="col-md-5 col-sm-5 col-lg-5" style="position:relative; left:-20px;">
     <label class="control-label">Param2</label>
<?php
$sqls="SELECT data_entry1.operation,operation_map.description,data_entry1.attribute_Code,attribute_map.description as attribute_map_description,param2   
FROM data_entry1,attribute_map,operation_map 
WHERE data_entry1.operation=operation_map.operation and 
data_entry1.attribute_code=attribute_map.attribute_code and 
param1 in (&#39;st_validate_partno_with_bom&#39;,&#39;st_validate_IQR_with_bom_by_serialno&#39;) and data_entry1.attribute_Code="
$strattributeID  ;
$dbquery1 =mssql_query($sqls);
?>

<?php
while($rws mssql_fetch_array($dbquery1)){
$myArray explode(&#39;,&#39;, $rws["param2"]);
?>

<select multiple class="form-control s-multiple" style="width: 120%; height: 350px;"  id="PresenterList" name="txtparam2[]">
<?php
 foreach ($myArray as $key => $value) { ?>

<option value="<?=$value?>"><?=$value?></option>
<?php
 }
?>

<?php
 }?>

</select>
    </div>
  </div>
</div>
<button type="submit" name="submit" value="submit" id="submit"  class="btn btn-success center2 btn-md"  onClick="return check();">Save</button>
<br>
<br>
</form>
« แก้ไขครั้งสุดท้าย: 08 มิถุนายน 2017, 11:02:21 โดย thammaratr » บันทึกการเข้า
หน้า: [1]   ขึ้นบน
พิมพ์