โค้ด: เลือกทั้งหมด
<?
require_once "../common.inc.php";
if ($_POST['bus_no'])
{
$sql1 = mysql_query("select emp_city from employee where emp_id={$_SESSION['MM_Emp_id']}");
$row1 = mysql_fetch_array($sql1);
$sql2 = mysql_query("select pro_id from product where bus_no={$_POST['bus_no']}");
$row2 = mysql_fetch_array($sql2);
$Y = date("Y")+543;
$time = date("H:i");
$date = date("d-m-Y");
$status_city = $row1['emp_city'];
$pro_id = $row2['pro_id'];
$bus_no = $_POST['bus_no'];
$sql = "insert into status (status_date,status_time,action_id,status_city,bus_no,pro_id)
value ('$date','$time','{$_POST['action_name']}','$status_city','$bus_no','$pro_id') ";
$result = mysql_query($sql);
if($result){
$report = "เพิ่มสถานะของรถเรียบร้อยแล้ว";
}
else{
$report = "ล้มเหลว";
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<?require_once "../header.inc.php"?>
<title>Goods Tracking System</title>
</head>
<body>
<div id="container">
<?require_once "../header.php"?>
<div id="wrapper">
<?require_once "../leftbar.inc.php"?>
<div id="content">
<div id="contenth2">เช็คสถานะสินค้า</div>
<div id="blog2">
<div id="blog02">
<? if ($report) { ?>
<table width="333" align="center">
<tr>
<td width="333" align='center'><font color='red'><?=$report?></font></td>
</tr>
</table>
<? } ?>
<form name="Formcp" method="post" action="" >
<table width="255" align="center">
<tr>
<td>สถานะ</td>
<td>
<select name="action_name" id="action_name">
<option>------- เลือกสถานะ -------</option>
<?=$actionList?>
</select>
</td>
</tr>
<tr>
<td width="78">รหัสรถ</td>
<td width="165">
<input type="text" name="bus_no" id="bus_no" id=targetfocus>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="Submit" value="Submit">
</td>
</tr>
</table>
</form>
</div>
</div>
<? } ?>
</div>
</div>
<?require_once "../footer.inc.php"?>
</div>
</body>
</html>
แต่ในตาราง product มี bus_no ที่ตรงกับ bus_noที่โพส หลายแถว
ทำไงให้มัน insert pro_id ทั้งหมดที่ bus_no ในตาราง product ตรงกับ bus_no ที่โพสอ่ะคะ แบบว่าinsert ทั้งหมดที่เจอออกมาเป็นหลายๆแถวค่ะ