Hello, Guest! Welcome to Symbianize Forum.

Most of our features and services are available only to our members. So we encourage you to login or join us by registering a new account. Registration is free, fast, and simple. You only need to provide a valid email address so we can minimize spammers. As a Symbianize member you'll have the following privileges:

  • Gain access to private forums and restricted features
  • Search the forums or post a reply
  • Download free applications, games, themes, graphics, tones, and videos
  • Ask question or support related to mobile phones, tablets, computers, game consoles, and multimedia
  • Private messaging (PM) with fellow members

All that and more, so what are you waiting for, join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

  • SYMBIANIZE TERMS AND RULES, EFFECTIVE DATE: March 28, 2022

Help pa help naman po sa PHP, backend CRUD error

DaMoon

Alipin
Joined
May 2, 2022
Messages
1
Points
1
Hello mga master, ask ko lang po bakit di nag e-echo yung status at di nagpapakita yung approve button(add) ano po kaya ang mali or kulang? Thank you po sa sasagot

DB Table:

dbdoc-jpg.1913412


admin webpage:
loa-jpg.1913415


PHP Code:

PHP:
<?php
    include("config.php");

 session_start();
    if(!isset($_SESSION['user'])){
        header("location: Login.php");
    }

    $user_check=$_SESSION['user'];
    $sql="SELECT * FROM users WHERE username='$user_check'";
    $stmt=$conn->query($sql);
    $row=$stmt->fetch(PDO::FETCH_ASSOC);
    $login_user=$row['name'];
    $login_access=$row['acc_type'];
  

    //code to update order
    if (isset($_POST['delUser'])){
        $sql=" UPDATE appointments SET status='Approved' WHERE appointment_id=:appointmentid";
        $stmt=$conn->prepare($sql);
        $stmt->execute([':appointmentid'=>$_POST ['appointment_id']]);

        $services=$_POST['services'];
        $sql="SELECT * FROM services WHERE services='$services'";
        $stmt=$conn->query($sql);
        $row=$stmt->fetch(PDO::FETCH_ASSOC);
        $stmt=$conn->query($sql);
    } 
?>

HTML Code:

HTML:
<div class="mt-sm-5"></div>
    <main role="main" class="container pt-3">
        <div class="card">
            <div class="card-header"><font color="black">
                <h2>List of Appointments</h2>
            </div>
            <div class="card body"><font color="black">
            <table class="table table-light">
            <?php
                 $sql = "SELECT * FROM appointments"; 
                $stmt=$conn->query('SELECT * FROM appointments');
                $row = $stmt->fetch(PDO::FETCH_ASSOC);
                if($row==null){ ?>
                    <td class="text-center">NO APPOINTMENTS</td>
                <?php }
                else{
            ?>
        <head>
            <tr>
                <th>Name</th>
                <th>Contact</th>
                <th>Services</th>
                <th>Doctors</th>
                <th>Status</th>
                <th>Action</th>
            </tr>
        </head>
        <tbody>
            <?php
                $sql = "SELECT * FROM appointments";
                $stmt=$conn->query('SELECT * FROM appointments');
                while($row=$stmt->fetch(PDO::FETCH_ASSOC)){
            ?>
            <tr>
                <td><?php echo $row['name']; ?></td>
                <td><?php echo $row['contact']; ?></td>
                 <td><?php echo $row['services']; ?></td>
                 <td><?php echo $row['doctor']; ?></td>
                <td><?php echo $row['status']; ?></td>
                <td>
                    <?php if($row['status']=="Pending"){?>
                    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#delModal" onclick="approveappointment_id(<?php echo $row['appointment_id'] ?> , '<?php echo $row['services'] ?>', )">Approve</button>
                    <?php }?>
                </td>
            </tr>
            <?php } }
                $conn = null;
            ?>
        </tbody>
    </table>

<!------------------- Modal to Approve Order -------------------->
    <div class="modal fade" id="delModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Approve Order</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                 <form action="" method="POST">
                <div class="modal-body">
                        <p>Approve order?</p>
                </div>
                <div class="modal-footer">
                    <input type="hidden" name="appointment_id" id="appointment_id">
                    <input type="hidden" name="services" id="services">
                    <input type="hidden" name="doctors" id="doctors">
                    <button type="submit" class="btn btn-primary" name="delUser">Yes</button>
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
                  
                </div>
                </form>
                </div>
            </div>
        </div>
    </div>

    </main>
         <?php }?>
         <?php if($login_access=="user"){?>
              <?php

header("location:restriction404.php");

               ?>

         <?php }?>
</body>
</html>
<script src="bootstrap/jquery/jquery-3.6.0.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
<script>
    function approveappointment_id(appointment_id, services, doctors){
        document.getElementById('appointment_id').value=appointment_id;
        document.getElementById('services').value=services;
        document.getElementById('doctors').value=doctors;
    }
</script>
 
Top