答案 0 :(得分:0)
如果您想在选择后显示内容,请更新此代码
<?php
session_start();
$page = null;
if (isset($_POST['page'])) {
$page = $_POST['page'];
$_SESSION['page'] = $page;
} else {
$page = $_SESSION['page'];
}
?>
<form name="myform" action="" method="post">
<select name="page" onchange="this.form.submit()">
<option value="page1"<?php if ($page == "page1") {
echo " selected";
} ?>>Page 1
</option>
<option value="page2"<?php if ($page == "page2") {
echo " selected";
} ?>>Page 2
</option>
<option value="page3"<?php if ($page == "page3") {
echo " selected";
} ?>>Page 3
</option>
</select>
</form>
<?php
switch ($page) {
case 'page3':
include_once('/path/to/page3content.php');
break;
case 'page2':
include_once('/path/to/page2content.php');
break;
case 'page1':
include_once('/path/to/page1content.php');
break;
default:
include_once('/path/to/defaultcontent.php');
break;
}
?>