|
|
|
สอบถามปัญหาการอัพเดทข้อมูลในแต่ละแถวโดยดึงข้อมูลจาก SQL และปุ่ม submit มีหลายอันตามข้อมูลแต่มีฟอร์มเดียว |
|
|
|
|
|
|
|
อันนี้เป็น code ครับอาจดูงงหน่อยครับ เพิ่งหัดเขียนได้ไม่นานครับ
Code (PHP)
<?php
require_once 'connectdb.php';
$qmanage = "SELECT * FROM machine_functional LEFT JOIN machine_tmec ON machine_functional.machine_id=machine_tmec.machine_id "
. "LEFT JOIN machine_equipment ON machine_functional.equip_id=machine_equipment.equip_id WHERE func_equiptype='Drypump'ORDER BY machine_tmec.machine_id";
//$qmanage = "SELECT * FROM machine_tmec LEFT JOIN pump_status ON machine_tmec.machine_id=pump_status.machine_id"
// . " RIGHT JOIN machine_functional ON pump_status.func_id=machine_functional.func_id"
// . " RIGHT JOIN machine_equipment ON pump_status.equip_id=machine_equipment.equip_id WHERE func_equiptype='Drypump'AND equip_status=1 ORDER BY machine_tmec.machine_id";
//$qmanage = "SELECT * FROM machine_functional INNER JOIN machine_tmec ON machine_functional.machine_id=machine_tmec.machine_id"
// . " LEFT JOIN ";
$resmanage = mysqli_query($dbcon, $qmanage);
$row= mysqli_fetch_array($resmanage);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
table,th,td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
<body>
<h2><center>Drypump Management</center></h2>
<form action="pumpmanage_update.php" name="frmpumpmange" method="POST" target="_blank"> <!--target="iframe_target">-->
<!--<iframe id="iframe_target" name="iframe_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>-->
<table style="" align="center">
<tr>
<th width="120">Machine</th>
<th width="200">Function</th>
<th width="240">Process Gas</th>
<th width="290">Pump</th>
<th width="210">Start</th>
<th width="210">Stop</th>
</tr>
<?php
while($rowmanage = mysqli_fetch_array($resmanage)){
echo "<tr>";
echo "<td><center>".$rowmanage['machine_id']." ".$rowmanage['abbr_name']."</center></td>";
echo "<td> ".$rowmanage['func_id']." ".$rowmanage['func_name']." (".$rowmanage['func_fullname'].")</td>";
echo "<td> ".$rowmanage['process_gas']." ".$rowmanage['equip_id']."</td>";
/////////////// Select Pump ////////////////////
if($rowmanage['equip_id'] == 0){
echo "<td> ".$rowmanage['func_id'];
echo "<select name='equip_id_select' id='equip_id'>";
echo "<option value=''>---Select Pump---</option>";
$qequip = "SELECT * FROM machine_equipment WHERE equip_type='Drypump' AND equip_status=0";
$resequip = mysqli_query($dbcon, $qequip);
while($rowequip = mysqli_fetch_array($resequip)){
echo "<option value=".$rowequip['equip_id'].">".$rowequip['brand']." ".$rowequip['model']." SN:".$rowequip['Serial_no']."</option>";
}
echo "</select> ";
//echo "<input type='hidden' name='func_id_select' value='$rowmanage[func_id]'>";
echo "<input style='background-color:lightgreen; width:55px; height:23px' name='submit1' type='submit' id='submit1' value='OK'>";
echo "</td>";
}else{
echo "<td> ".$rowmanage['brand']." ".$rowmanage['model']." SN:".$rowmanage['Serial_no']."</td>";
}
/////////////// Start date //////////////////////
if($rowmanage['equip_id'] == 0){
echo "<td><center>-</center></td>";
}elseif($rowmanage['start_used'] == '0000-00-00' AND $rowmanage['equip_id'] != 0){
echo "<td><center>".$rowmanage['func_id']."<input name='start_used' type='date' id='start_used'> ";
//echo "<input type='hidden' name='func_id_start' value='$rowmanage[func_id]'>";
//echo "<input type='hidden' name='equip_id_select' value='$rowmanage[equip_id]'>";
echo "<input style='background-color:lightgreen; width:55px; height:23px' name='submit2' type='submit' id='submit2' value='Start')></center></td>";
}else{
echo "<td><center>".$rowmanage['func_id']."".$rowmanage['start_used']."</center></td>";
}
/////////////// Stop date //////////////////////
if($rowmanage['start_used'] == ''){
echo "<td><center>-".$rowmanage['func_id']."</center></td>";
}else{
echo "<td><center>".$rowmanage['func_id']."<input name='stop_used' type='date' id='stop_used'> ";
//echo "<input type='hidden' name='func_id_stop' value='$rowmanage[func_id]'>";
echo "<input style='background-color:lightgreen; width:55px; height:23px' name='submit3' type='submit' id='submit3' value='Stop')></center></td>";
}
echo "</tr>";
}
?>
</table>
</form>
</body>
</html>
ส่วนอันนี้เป็นอีกไฟล์ที่ให้แสดงค่า ID เมื่อกดปุ่มครับ
Code (PHP)
<?php
require_once 'connectdb.php';
$manage_func_id_select = $_POST['func_id_select'];
$manage_func_id_start = $_POST['func_id_start'];
$manage_func_id_stop = $_POST['func_id_stop]'];
$manage_equip_id = $_POST['equip_id_select'];
$manage_start_date = $_POST['start_date_select'];
$manage_stop_date = $_POST['stop_date_select'];
$manage_select = $_POST['select'];
echo "func_id_select =".$manage_func_id_select."<br>";
echo "func_id_start =".$manage_func_id_start."<br>";
echo "func_id_stop =".$manage_func_id_stop."<br>";
echo "equip_id =".$manage_equip_id."<br>";
echo "start_date =".$manage_start_date."<br>";
echo "stop_date =".$manage_stop_date."<br>";
echo "select =".$manage_select."<br>";
|
ประวัติการแก้ไข 2016-03-02 15:26:35 2016-03-02 15:26:59 2016-03-02 15:30:51
|
|
|
|
Date :
2016-03-02 15:25:03 |
By :
jakgarin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำได้แล้วครับ
|
|
|
|
|
Date :
2016-03-03 15:05:10 |
By :
jakgarin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2016-03-04 09:30:32 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|