<?php
include("dbconfig.php");
if(isset($_POST['type'])== "enquiry")
{
query for enuiry;
}
else{
query for enroll;
}
?>
<form action="dropd.php" method="POST">
<select name="type">
<option>Please select:</option>
<option value="enquiry">Student enquiry</option>
<option value="enroll">Student enrollment</option>
<input type="submit" name="submit" value="SUBMIT">
</select>
</form>
嗨..我想根据下拉选择运行两个不同的SQL查询。我不知道该怎么做。我很新鲜的PHP。请指导我。
答案 0 :(得分:1)
<?php
include("dbconfig.php");
if(isset($_POST['submit']))
{
if(isset($_POST['type']))
{
if($_POST['type'] == "enquiry")
{
Query
}
elseif($_POST['type'] == "enroll")
{
Query
}
else
{
echo "Please select enquiry or enrollment";
}
}
else
{
echo "Please select an option";
}
}
?>
<form action="dropd.php" method="POST">
<select name="type">
<option value="">Please select:</option>
<option value="enquiry">Student enquiry</option>
<option value="enroll">Student enrollment</option>
<input type="submit" name="submit" value="SUBMIT">
</select>
</form>
答案 1 :(得分:0)
您的代码应为:
<?php
include("dbconfig.php");
if(isset($_POST['submit'])){
if(isset($_POST['type']) && $_POST['type'] == "enquiry")
{
query for enuiry;
} else {
query for enroll;
}
}
?>
<form action="dropd.php" method="POST">
<select name="type">
<option value=''>Please select:</option>
<option value="enquiry">Student enquiry</option>
<option value="enroll">Student enrollment</option>
</select>
<input type="submit" name="submit" value="SUBMIT">
</form>