由於我已經有下拉列表中的數據,我該如何反映它在數據庫中?數據庫應該顯示確切的管理員編號,學生,gpa和下拉列表中的一個選項。我需要使用if else語句嗎?如何從下拉列表中插入數據到數據庫
<form name="IT" action="getIT_now.php" method="post">
<?php
$result = mysqli_query($con,"SELECT admin_no, name, GPA, gender FROM student_details WHERE jobscope1= 'IT' ORDER BY `GPA` DESC; ");
$result2 = mysqli_query($con, "SELECT job_title FROM job_details WHERE jobscope='IT';");
$row2 = mysqli_fetch_assoc($result2);
echo "<table border='1' >
<tr>
<th>Admin Number</th>
<th>Student Name</th>
<th>GPA</th>
<th>Gender</th>
<th>Company List</th>
</tr>";
/*options sections start*/
$options= '';
while ($row2 = mysqli_fetch_array($result2))
{
$options .='<option value="'. $row2['job_title'] .'"> '. $row2['job_title'] .'</option>';
}
/*options sections end*/
while($row = mysqli_fetch_assoc($result))
{
echo "<tr>";
echo "<td bgColor=white>" . $row['admin_no'] . "</td>";
echo "<td bgColor=white>" . $row['name'] . "</td>";
echo "<td bgColor=white>" . $row['GPA'] . "</td>";
echo "<td bgColor=white>" . $row['gender'] . "</td>";
echo "<td><select name='ddl' onclick='if(this.value != '') { myform.submit(); }'>".$options."</select></td>";
}
echo "</tr>";
echo "</table>";
?>
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
你做了什麼嘗試呢? – sunshinekitty
你的意思是你需要在頁面上進行動態更改嗎?恐怕不能用PHP完成,你需要使用Javascript。 – Alexander
@ 0n35我還沒有做任何事情,因爲我不知道如何將數據從下拉列表中插入到數據庫中。 – Angelica