当前位置:Gxlcms > PHP教程 > select-php如何读取下拉菜单选中数据

select-php如何读取下拉菜单选中数据

时间:2021-07-01 10:21:17 帮助过:9人阅读

selectphp下拉菜单

$con = mysqli_connect($db_hostname,$db_username,$db_password,$db_database);if (!$con) die("Unable to connect to MySQL: ".mysqli_connect_error());$query = "select * from tutorials";$result = mysqli_query($con,$query);$result || die("Database access failed: ".mysqli_error($con));$rows = mysqli_num_rows($result);while ($row = mysqli_fetch_assoc($result)) {    echo "Day: ", $row["day"],"
\n"; echo "Time: ", $row["time1"],"
\n"; echo "Available: ", $row["available2"],"
\n"; echo "Time: ", $row["time2"],"
\n"; echo "Available: ",$row["available"],"

\n";}

?>

Please choose a day from above timetable:


Select a day
$query = "select day from tutorials";
$result = mysqli_query($con,$query);
$result || die("Database access failed: ".mysqli_error($con));
while ($rows = mysqli_fetch_assoc($result)) {
?>

Please choose one time:


Select a time
if(isset($_POST['submit']))
$day = $_POST['selectDay'];
echo "The day is $day";
$query = "select time1 from tutorials where day='$day'";
$result = mysqli_query($con,$query);
$result || die("Database access failed: ".mysqli_error($con));
?>

人气教程排行