我有一个.php页面,允许用户通过显示每个专家的表单来选择专家的时间段,但是当我选择数据库必须使用新值更新时,但事实并非如此。
这是 assigntotimeslot.php 中的表单代码,但专家列表显示正常。
<?php
$qry=" SELECT * FROM Specialist"; //selecting all specialists to display
$result =mysql_query($qry); //create query
//check whether it was successful or not
if($result) {
$did = 0;
Print " <table style='width:100%'>";
while($info=mysql_fetch_array($result))
{
if($did==0){
Print "<form action='assigntotimeslot_php.php?id='".$info['Spec_ID']."' method='POST' enctype='multipart/form-data' style='display:inline;'
<tr>
<td><figure style='text-align:centre;'>
<img STYLE='border: thin solid grey;left:00px;top:00px;'src='img/idimg.jpg' alt='idimage' width='110' height='110'>
<figcaption>".$info['Spec_Name']."<br/>".$info['Spec_ID']."<br/>".$info['Specialty']. "</br> From: <select name='cars'>
<option name='Time_in' value='08:00'>08:00AM</option>
<option name='Time_in' value='09:00'>09:00AM</option>
<option name='Time_in' value='10:00'>10:00AM</option>
<option name='Time_in' value='11:00'>11:00AM</option>
<option name='Time_in' value='12:00'>12:00AM</option>
<option name='Time_in' value='02:00'>02:00PM</option>
<option name='Time_in' value='04:00'>04:00PM</option>
<option name='Time_in' value='05:00'>05:00PM</option>
</select>
TO: <select name='cars'>
<option name='Time_out' value='08:00'>08:00PM</option>
<option name='Time_out' value='09:00'>09:00PM</option>
<option name='Time_out' value='10:00'>10:00PM</option>
<option name='Time_out' value='11:00'>11:00PM</option>
<option name='Time_out' value='12:00'>12:00PM</option>
<option name='Time_out' value='02:00'>02:00PM</option>
<option name='Time_out' value='04:00'>04:00PM</option>
<option name='Time_out' value='05:00'>05:00PM</option>
<input name='Submit' type='submit' value='Assign' /> </br></br></br></figcaption>
</figure></td> </form>";
$did++;
continue; }
if($did==1){
Print "<form action='assigntotimeslot_php.php?id='".$info['Spec_ID']."' method='POST' enctype='multipart/form-data' style='display:inline;'
<tr>
<td><figure style='text-align:centre;'>
<img STYLE='border: thin solid grey;left:00px;top:00px;'src='img/idimg.jpg' alt='idimage' width='110' height='110'>
<figcaption>".$info['Spec_Name']."<br/>".$info['Spec_ID']."<br/>".$info['Specialty']. "</br> From: <select name='cars'>
<option name='Time_in' value='08:00'>08:00AM</option>
<option name='Time_in' value='09:00'>09:00AM</option>
<option name='Time_in' value='10:00'>10:00AM</option>
<option name='Time_in' value='11:00'>11:00AM</option>
<option name='Time_in' value='12:00'>12:00AM</option>
<option name='Time_in' value='02:00'>02:00PM</option>
<option name='Time_in' value='04:00'>04:00PM</option>
<option name='Time_in' value='05:00'>05:00PM</option>
</select>
TO: <select name='cars'>
<option name='Time_out' value='08:00'>08:00PM</option>
<option name='Time_out' value='09:00'>09:00PM</option>
<option name='Time_out' value='10:00'>10:00PM</option>
<option name='Time_out' value='11:00'>11:00PM</option>
<option name='Time_out' value='12:00'>12:00PM</option>
<option name='Time_out' value='02:00'>02:00PM</option>
<option name='Time_out' value='04:00'>04:00PM</option>
<option name='Time_out' value='05:00'>05:00PM</option>
<input name='Submit' type='submit' value='Assign' /> </br></br></br></figcaption>
</figure></td></tr> </form>";
$did--;
}
}
Print " </table>";
}
else echo "There are no specialists";
?>
以下是 assigntotimeslot_php.php
中的代码// Start database connection
$Time_in = (isset($_POST['Time_in']) ? $_POST['Time_in'] : null);
$Time_out = (isset($_POST['Time_out']) ? $_POST['Time_in'] : null);
//Create query
$qry="UPDATE Specialist SET Time_in='".$Time_in."',Time_out='".$Time_out."";
$result=mysql_query($qry);
答案 0 :(得分:0)
您已为选项命名。你应该给选择标签命名。
而不是
<select name='cars'>
<select name='Time_in'>
和<select name='Time_out'>