I have a HTML form with dropdown list populated by php. I want the user to be able to select an option from the dropdown list and click on "Proceed" button which would open a new page based on the selected value.
<form name="selectPatient" method="post">
<div align="centre">
<select name="patient_dropdown">
<?php
include "connection.php";
$sql = mysql_query("SELECT Name from patient_info");
while ($row = mysql_fetch_array($sql)) {
echo "<option value=".$row['Name'].">".$row['Name']."</option>";
}
?>
</select>
</div>
<br>
<br>
<input type="submit" name="submit" value="Proceed"/>
</form>
<?php
if(isset($_POST['submit'])) {
header("Location: http://localhost/lei/test.com/proper/specific_patient.php");
}
?>
The code above works fine. How do I get the selected value from dropdown list?? I want to use the selected value to run a SQL query using php to get other details of the patient and then call a javascript file with that information. How can I do that??
Thanks in advance !
您需要在提交时检查$ _POST变量:
$patient_dropdown = isset($_POST['patient_dropdown']) ? $_POST['patient_dropdown'] : false;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.