当调度程序选择更新数据库所需的驱
这是我到目前为止所不知道从哪里开始的。
$sql = "SELECT * FROM dispatch WHERE driver = '' OR pu_time = '' OR do_time = ''";
$result = mysql_query($sql);
$i = 0;
$color1 = "#ff0000";
$color2 = "#00ff00";
while($row = mysql_fetch_array($result)){
if($i%2 == 1) {$color = $color1;}
else {$color = $color2;}
echo "<tr style='background-color: $color'>";
echo '<td><input name="id" type="hidden" value="'.$row['id'].'" />'.$row['call_time'].'</td>';
echo "<td>".$row['start_address']."</td>";
echo "<td>".$row['end_address']."</td>";
echo "<td>".$row['phone']."</td>";
echo "<td>".$row['puat']."</td>";
if (isset($row['driver']) === true && empty($row['driver']) === true){
echo '<td>
<form id = "driver">
<select name="driver">
<option value="Mike">Mike</option>
<option value="Cheek">Cheek</option>
<option value="Spencer">Spencer</option>
<option value="Melissa">Melissa</option>
</select>
</form></td>';
}
else {
echo "<td>".$row['driver']."</td>";
}
echo "</tr>";
$i++;
}
}
答案 0 :(得分:0)
我想出了一个非常粗糙的工作......如果有人有更好的想法,我愿意接受它!
$sql = "SELECT * FROM dispatch WHERE driver = '' OR pu_time = '' OR do_time = ''";
$result = mysql_query($sql);
$i = 0;
$color1 = "#ff0000";
$color2 = "#00ff00";
while($row = mysql_fetch_array($result)){
if($i%2 == 1) {$color = $color1;}
else {$color = $color2;}
echo "<tr style='background-color: $color'>";
echo '<td><input name="id" type="hidden" value="'.$row['id'].'" />'.$row['call_time'].'</td>';
echo "<td>".$row['start_address']."</td>";
echo "<td>".$row['end_address']."</td>";
echo "<td>".$row['phone']."</td>";
echo "<td>".$row['puat']."</td>";
if (isset($row['driver']) === true && empty($row['driver']) === true){
echo '<td>
<form id = "driver">
<select name="driver" onchange="this.form.submit()">
<option value="Mike">Mike</option>
<option value="Cheek">Cheek</option>
<option value="Spencer">Spencer</option>
<option value="Melissa">Melissa</option>
</select>
</form></td>';
if (isset($_GET['driver'])){
$new_driver = $_GET['driver'];
$id = $row['id'];
$update_d = "UPDATE dispatch SET driver = '$new_driver' WHERE id = '$id'";
mysql_query($update_d,$con)
or die;
unset($_GET['driver']);
echo '<script type="text/JavaScript">
window.location.href = "new_index.php";
</script>';
}
}
else {
echo $_GET['driver']."Hello";
echo "<td>".$row['driver']."</td>";
}
echo "</tr>";
$i++;
}
}