<?php
include('connexion.php');
include('security.php');
include('includes/header.php'); 
include('includes/navbar.php'); 



?>


<body>


    <?php

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

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

<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="select * from (voiture v right join location l on (v.id_voiture=l.id_voiture)) inner join user u on (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>status</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="id_location" 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="id_location" 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 include('includes/scripts.php');

?>

I don't have the time right now to read your code, but you could use javascript to make an HTML button disabled after clicking it, until it's processed by the server. Personally, I use jQuery, but I do realize jQuery is going out of favor recently.

i don't know how using javascript to disable the button after changing the status

i wanna the condition in javascript to disable the button

<script >


function disableBtn() {

  document.getElementById("myBtn").disabled = true;
}
}




<td><form method="post" action="">
        <input type="hidden" name="id_location" value="<?php echo $row['id_location']; ?>">
        <button  type="submit" name="approved" id="myBtn" onclick="disableBtn()"class="btn btn-success"  >approved</button></form></td>
    <td><form method="post"  action="">
<input type="hidden" name="id_location" value="<?php echo $row['id_location']; ?>">
        <button type="submit" name="rejected"id="myBtn" onclick="disableBtn()"class="btn btn-danger"  >reject</button></form></td>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.