Hi everyone here,
I'm trying to show information about the material according to the year of meeting(is a meeting when they decide to buy a new material)
so I use a drop-down list and the information will show according to the year chosen by the user, but it shows the error as is mentioned in the title.
this the code.
Thanks in advance.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div class="container">
<form method="POST" action="" name="form">
<div class="row">
<div class="col-25">
<label for="year">annee marche</label>
</div>
<div class="col-75">
<?php
require("connexion.php");
$sql = "SELECT DISTINCT(annee) FROM marche";
$result = mysqli_query($conn, $sql);
print '<select name="year">';
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
print '<option value="'.$row ['annee'].'" >'.$row ['annee'].'</option>';
}}
print '</select>';
?>
</div></div>
</form>
</div>
<div >
<table class="table">
<thead>
<tr>
<th>material</th>
<th>serial number</th>
<th> inventory number </th>
<th>type</th>
<th>state</th>
<th>number_meeting</th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php require("connexion.php");
// if ($_SERVER["REQUEST_METHOD"] == "POST"){
$an=mysqli_real_escape_string($conn,$_POST["year"]);
$sql="SELECT id_mat, libelle_mat, num_serie, num_inv,etat,libelle_type,num_mar FROM materiel,type,marche WHERE type.id_type_mat=materiel.id_type_mat
AND marche.id_mar=materiel.id_mar
AND marche.annee =".$an;
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// Parcourir les lignes de résultat
while($row = mysqli_fetch_assoc($result)) {
echo "<tr><td>".$row["libelle_mat"]
."</td><td>".$row["num_inv"]
."</td><td>".$row["num_serie"]
."</td><td>".$row["libelle_type"]
."</td><td>".$row["etat"]
."</td><td>".$row["num_mar"]
."</td><td><a href=\"modify.php?id_mat=".$row["id_mat"]."\"></a>"
."</td><td><a href=\"supp.php?id_mat=".$row["id_mat"]."\" onclick=\"confirm('هل تريد حقا الحذف')\"></a></td><td><a href=\"showrepa.php?id_mat=".$row["id_mat"]."\"></a>"
."</td><td><a href=\"bureaux.php?id_mat=".$row["id_mat"]."\"></a>"
."</td></tr><br>";
}
}
?>
</tbody>
</table></div>
</body>
</html>