Ajouter boutton approved et reject

bayssa1998 -  
yg_be Messages postés 23541 Date d'inscription   Statut Contributeur Dernière intervention   -
Bonjour,
Je dois ajouter un bouton d'acceptation et de refus sur chaque ligne et lorsque j'ai cliqué sur approuvé le changement d'etat en approuvé et lorsque j'ai cliqué sur rejeter le changement d'etat sur rejeté, la valeur par défaut du etat est (en cours), les boutons ne seront pas cliquables.

<?php
include('connexion.php');
include('security.php');
include('includes/header.php');
include('includes/navbar.php');
?>
<body>
<div class="container-fluid">

<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">
Rentals</h6>

</div>
<div class="card-body">

<div class="container">

<div class="row justify-content-center">


<?php

$query="SELECT * from voiture v,location l,user u where v.id_voiture=l.id_voiture AND l.id_user=u.id_user";


$query_run=mysqli_query($connection,$query);
if(mysqli_num_rows($query_run)>0){



?>
<table class="table">
<thead>
<tr><th>User</th>
<th>Car</th>
<th>Modele</th>
<th>Type</th>
<th>mileage</th>
<th>prix</th>
<th>from date</th>
<th>to date</th>
<th>person</th>
<th>luggage</th>
<th>state</th>
<th >accept</th>
<th >Delete</th>
</tr>
</thead>
<tbody>


<?php
while ($row=mysqli_fetch_assoc($query_run)) {


?>

<tr>

<td><?php echo $row['username'];?></td>
<td><?php echo $row['nom'];?></td>
<td><?php echo $row['model'];?></td>
<td><?php echo $row['type'];?></td>
<td><?php echo $row['kilometrage'];?></td>
<td><?php echo $row['prix'];?></td>
<td><?php echo $row['from_date'];?></td>
<td><?php echo $row['to_date'];?></td>
<td><?php echo $row['person'];?></td>
<td><?php echo $row['luggage'];?></td>
<td><?php echo $row['etat'];?></td>

<td><form method="post" action="">
<input type="hidden" name="approved" value="<?php echo $row['id_location']; ?>">
<button type="submit" name="approved" class="btn btn-success">approved</button></form></td>
<td><form method="post" action="">
<input type="hidden" name="rejected" value="<?php echo $row['id_location']; ?>">
<button type="submit" name="rejected" class="btn btn-danger">reject</button></form></td>




<?php

if(isset($_POST["approved"]))
{
$id_location=$_POST['id_location'];
$sql="UPDATE location SET etat = 'Approved' WHERE id_location = '$id_location'";
$result=mysqli_query($connection,$result);
}
?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>

</div>




</form>






<?php include('includes/scripts.php');

?>

Configuration: Windows / Chrome 89.0.4389.114
A voir également:

1 réponse

yg_be Messages postés 23541 Date d'inscription   Statut Contributeur Dernière intervention   Ambassadeur 1 584
 
bonjour,
peux-tu partager le code html reçu par le navigateur?
0
bayssa1998
 
le code php
0
bayssa1998
 
<?php
include('connexion.php');
include('security.php');
include('includes/header.php');
include('includes/navbar.php');

?>
<body>
<div class="container-fluid">

<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">
Rentals</h6>

</div>
<div class="card-body">

<div class="container">

<div class="row justify-content-center">


<?php

$query="SELECT * from voiture v,location l,user u where v.id_voiture=l.id_voiture AND l.id_user=u.id_user";


$query_run=mysqli_query($connection,$query);
if(mysqli_num_rows($query_run)>0){



?>
<table class="table">
<thead>
<tr><th>User</th>
<th>Car</th>
<th>Modele</th>
<th>Type</th>
<th>mileage</th>
<th>prix</th>
<th>from date</th>
<th>to date</th>
<th>person</th>
<th>luggage</th>
<th>state</th>
<th >accept</th>
<th >Delete</th>
</tr>
</thead>
<tbody>


<?php
while ($row=mysqli_fetch_assoc($query_run)) {


?>

<tr>

<td><?php echo $row['username'];?></td>
<td><?php echo $row['nom'];?></td>
<td><?php echo $row['model'];?></td>
<td><?php echo $row['type'];?></td>
<td><?php echo $row['kilometrage'];?></td>
<td><?php echo $row['prix'];?></td>
<td><?php echo $row['from_date'];?></td>
<td><?php echo $row['to_date'];?></td>
<td><?php echo $row['person'];?></td>
<td><?php echo $row['luggage'];?></td>
<td><?php echo $row['etat'];?></td>

<td><form method="post" action="">
<input type="hidden" name="approved" value="<?php echo $row['id_location']; ?>">
<button type="submit" name="approved" class="btn btn-success">approved</button></form></td>
<td><form method="post" action="">
<input type="hidden" name="rejected" value="<?php echo $row['id_location']; ?>">
<button type="submit" name="rejected" class="btn btn-danger">reject</button></form></td>





</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>

</div>




</form>

<?php

if(isset($_POST["approved"]))
{
$id_location=$_POST['id_location'];
$sql="UPDATE location SET etat = 'Approved' WHERE id_location = '$id_location'";
$result=mysqli_query($connection,$sql);
}
if(isset($_POST["rejected"]))
{
$id_location=$_POST['id_location'];
$sql="UPDATE location SET etat='Rejected' WHERE id_location = '$id_location'";
$result=mysqli_query($connection,$sql);
}
?>




<?php include('includes/scripts.php');

?>
0
yg_be Messages postés 23541 Date d'inscription   Statut Contributeur Dernière intervention   1 584 > bayssa1998
 
merci d'utiliser les balises de code, comme expliqué ici: https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code

peux-tu partager la source HTML de la page, que tu peux obtenir dans le navigateur, après affichage?
0