这是目标:用户需要查看特定类别的问题。这是列表中最古老的问题。这是我使用的代码,但其中有错误。当我单击“Zoeken”按钮时,什么也没有发生。页面刚刚刷新。有什么帮助吗?
<form method="post" action="<?php echo $_SERVER["h5/PHP_SELF"] ?>">
Selecteer een categorie:<select name="categorieid">
<?php
$db=mysql_connect("localhost","*****","******") or die("Kan niet verbinden: ".mysql_error());
mysql_select_db("*****",$db);
$sql = "SELECT * FROM Categorie";
$resultaat = mysql_query($sql); // voer SQL code uit
while ($rij = mysql_fetch_array($resultaat)) {
echo "<option value=\"";
echo $rij["Categorie_ID"]."\">";
echo $rij["Categorienaam"]."</option>\n";
}
mysql_close($db);
?>
//de tabel weergeven
<?php
if ($_POST["Zoek"]) {
$_POST["categorieid"];
$db=mysql_connect("localhost","********","********") or die("Kan niet verbinden: ".mysql_error());
mysql_select_db("**********",$db);
$sql = "SELECT * FROM Probleem";
if(isset($_POST["categorieid"])){
$cat_id = $_POST["categorieid"];
//sanitize $cat_id to reduce injection risk here
$sql .= " WHERE Categorie_ID = $cat_id"; //use correct column name
}
$sql .= " ORDER BY Datum ASC";
$resultaat = mysql_query($sql); // voer SQL code uit
echo "<table border=1>";
echo "<tr><td><b>Probleem_ID</b></td><td><b>Categorie</b></td><td><b>Datum</b></td><td><b>Omschrijving;</b></td><td><b>Gebruiker_ID</b></td><td><b>Oplossing</b></td></tr>"; // bovenste regel
if ($resultaat) {
while ($rij = mysql_fetch_array($resultaat)) {
echo "<tr>";
echo "<td>".$rij['Probleem_ID']."</td>";
echo "<td>".$rij['Categorie_ID']."</td>";
echo "<td>".$rij['Datum']."</td>";
echo "<td>".$rij['Probleem']."</td>";
echo "<td>".$rij['Gebruiker_ID']."</td>";
echo "<td>".$rij['Oplossing']."</td>";
echo "</tr>";
}
}
echo "</table>";
mysql_close($db);
}
?>
<form name="form1" method="post" action="">
<input type="submit" name="Zoek" id="Zoek" value="zoek">
</form>