Bonjour,
Voila je rencontre un petit problème avec mon code.
je suis entrain de créer un petit tableau en html qui affiche mes donnée dans une tabl sql dans ma base de donner , ce que je veux faire c'est de metrre un button a la fin de chaque ligne (une ligne tt les information d'un client ) qui supprime ce client de la base de donné
<?php
$connection = mysql_connect('localhost', 'root', '');
mysql_select_db('res_bd');
/* location 0 */
$query2 = " select id_bien,superficie,nbr_piece,adresse,departement,description_bien,prix,nom,prenom from bien,profil where (transaction = 0) and (id_agent = id_profil)" ;
$locations = mysql_query($query2);
/* vente 1 */
$query3 = "select id_bien,superficie,nbr_piece,adresse,departement,description_bien,prix,nom,prenom from bien,profil where (transaction = 1) and (id_agent = id_profil) " ;
$ventes = mysql_query($query3);
?>
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<title> acceuil </title>
</head>
<body>
<br> <br> <br>
<form action="agent.php" method="POST" >
<?php
echo "LISTE DES BIENS POUR LOCATION";
echo "<table border = '1'>";
echo
"<tr>
<th> Superficie maison </th>
<th> Adresse </th>
<th> Departement </th>
<th> Nombre pieces </th>
<th> Description bien </th>
<th> Prix </th>
<tr>";
while($row = mysql_fetch_array($locations)){
echo "<tr>
<td '>" . $row['superficie'] . "</td>
<td>" .$row['adresse']."</td>
<td '>" . $row['departement'] . "</td>
<td>" . $row['nbr_piece'] . "</td>
<td '>" . $row['description_bien'] . "</td>
<td>" . $row['prix'] . "</td>
</tr>";
}
?>
<br> <br> <br>
<?php
echo "LISTE DES BIEN PROPOSER A LA VENTE";
echo "<table border = '1'>";
echo
"<tr>
<th> Superficie maison </th>
<th> Adresse </th>
<th> Departement </th>
<th> Nombre pieces </th>
<th> Description bien </th>
<th> Prix </th>
<th> </th>";
while($row = mysql_fetch_array($ventes))
{
echo "<tr>
<td '>" . $row['superficie'] . "</td>
<td>" .$row['adresse']."</td>
<td '>" . $row['departement'] . "</td>
<td>" . $row['nbr_piece'] . "</td>
<td '>" . $row['description_bien'] . "</td>
<td>" . $row['prix'] . "</td>";
}
?>
<!--<td> <input type="submit" name="vendu" value="Vendu" id=". $row['id_bien'] ."> </td>-->
<td>
<input type="submit" name="supprimer" value="Supprimer" >
<input type="hidden" name="b_id" value="<?=$fetcher['id_bien'] ?>"/>
</td>
<?php
echo " </tr> ";
?>
<?php
if (isset($_POST['supprimer']))
{
$boking_id = (int) $_POST['b_id'];
mysqli_query($connection, "DELETE FROM `bien` where id_bien= '".$boking_id."'");
if(mysqli_affected_rows($connection))
{
echo "success";
}
else{
echo "faild";
}
}
if($_GET){
if(isset($_POST[‘vendu’]))
{
$id = $_GET['id_bien'];
$query4 = "UPDATE `bien` SET `disponible`= 0 where id_bien = $id ";
mysql_query($query4);
}
if (isset($_POST['supprimer']))
{
$boking_id =(int) $_POST['b_id'];
mysqli_query($connection, "DELETE FROM `bien` where id_bien= '".$boking_id."'");
if(mysqli_affected_rows($connection))
{
echo "success";
}
else{
echo "faild";
}
}
}
?>
</form>
</body>
</html>