how disable button accept and reject after changing status?

btissam

New member
Local time
Today, 18:52
Joined
Apr 7, 2021
Messages
1
how disable buttons accept and reject after changing the status to approved or rejected of each row (when the user do a rental in website .In admin panel the admin have to accept or refuse the rental then the status has change to approved if he choose accept and rejected if he choose refuse and then the buttons should be disable).
Code:
<?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 >refuse</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>
 
Hi, you can try:
PHP:
// ...
              <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"<?php echo $row['etat'] !== null ? " disabled" : ""; ?>>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"<?php echo $row['etat'] !== null ? " disabled" : ""; ?>>reject</button>
                      </form>
                    </td>
                    </td>  // <-- *** this close tag does not seem to have a matching open tag ***
                  </tr>
                <?php } ?>
              </tbody>
// ...

[Note, I edited to add in missing semi-colons 😬 ]
 
Last edited:
Also, in the last line of the code you posted, you have a close form tag (</form>) which doesn't appear to have a matching open form tag. :oops:
 

Users who are viewing this thread

Back
Top Bottom