当我从选择菜单中选择元素时,如何显示表中的其他元素?正如您在下面的链接中看到的那样,我试图做一些事情,但我没有看到任何:(
http://faous.net/test/profile/page1.php
<html>
<header>
<title>test PHP</title>
</header>
<body>
<h1>Formulaire</h1>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="get">
<?php
echo "<select name='sub1'>";
while($row=mysql_fetch_array($result)){
echo "<option value='" . $row['nom'] . "'>" . $row['nom'] . "</option>";
}
echo "</select>";
echo "<br />";
$result2=mysql_query($sql);
$base=mysql_fetch_array($result2);
//$nnnn= $_GET["nom"];
//$aaaa=$_GET["base"];
//$bbbb=$_GET["hauteur"];
//$cccc=$_GET["rayon"];
$nnnn = $_GET[$row];
$aaaa = $_GET["base"];
$bbbb = $_GET["hauteur"];
$cccc = $_GET["rayon"];
echo "Nom: $nnnn <br /> Base: $aaaa <br /> Hauteur: $bbbb<br /> Rayon: $cccc";
echo "<br /> ";
?>
</form>
</body>
</html>
<?php
mysql_close($link);
?>
您必须像这样提交更改选择的表格,
<select onchange="this.form.submit()">
在您的情况下,
echo "<select name='sub1' onchange='this.form.submit()'>";
mysql_*
已弃用,请改用mysqli_*
或PDO
这些台词是完全错误的
$result2=mysql_query($sql);// what is $sql here??
$base=mysql_fetch_array($result2);
$nnnn = $_GET[$row];// what is $row??
$aaaa = $_GET["base"]; // where is the form element with name base??
$bbbb = $_GET["hauteur"]; // where is the form element with name hauteur??
$cccc = $_GET["rayon"]; // where is the form element with name rayon??