您将需要将您的“选择”包装在一个表单中并使用这样的按钮..
<style type="text/css">
/* just styling the overall menu */
#my-post-link ul{
list-style-type:none;
text-align:center;
background-color:cadetblue;
font-size:1.1em;
font-weight:600;
padding:0.45em;
line-height: 1.75em;
}
/* following line would allow you to create a horizontal menu */
#my-post-link ul li{display:inline;white-space:nowrap;}
#my-post-link button {
background-color: transparent; /* <-- removes the gray button */
border: none; /* <-- removes the border around the button */
color: white;
font-size: 1.15em;
font-weight: 600;
}
#my-post-link button:hover {
background-color: white;
color: cadetblue;
cursor: pointer; /* <-- makes the button text act like a link on hover */
}
</style>
<form id="myForm" name="myForm" method="post">
<div id="my-post-link"><ul>
<li><button name="select-me" type="submit" value="var" onclick=\"myForm.action='./page.php';return true;\">Click me!</li>
</ul></div>
</form>
这将使用键“select-me”将值“var”发布到 page.php,因此您可以使用...读取该变量
$variable = $_POST["select-me"];
您还可以使用伪类进一步设置按钮的样式,以使它们的行为更像常规文本链接,但我认为您明白了。
如果您想查看哪些变量正在 POST 回您的页面,您可以将此代码放在某处:
foreach ($_POST as $key => $value) {
$i++;
${$key} = $value;
echo "<!-- //[{$i}] {$key}:{$value} -->\n";
}
您还可以使用 var_dump($_POST) 查看 POST 数据