简体   繁体   中英

how do i select a single user transaction log from the database, it should fetch only the logged in transaction log

how do i select a single user transaction log from the database, it should fetch only the logged in transaction log i tried with this line of code but it is fetching all the user transaction instead of the current logged in user. what can i do please

<?php

                $sql = "SELECT * FROM admin_dept_table";
                $query_run = mysqli_query($conn, $sql);

            ?>

            <table class="display table"  id="example">
                                <thead>
                                    <tr class="info">
                
                  <th>Amount(USD)</th>
                                        <th>Status</th>
                                        <th>Tnx ID</th>
                                        <th>Date</th>
                                    </tr>
                                </thead>

          
    

                            
                                <tbody>

                <?php
    
            if(mysqli_num_rows($query_run) > 0)
            {

                while($row = mysqli_fetch_assoc($query_run)){


                    ?>
            
           <tr>
                    
                   
                    <td> <?php echo $row['amount']; ?></td>
                    <td> <?php echo $row['status']; ?></td>
                    <td> <?php echo $row['transactionid']; ?></td>
                    
                    <td> <?php echo $row['date']; ?></td>
                    
                  </tr>
                  <?php
                }
            }else{
                echo "no record found";
            }

      ?>
    
                                </tbody>
</table>

Think you can add condition to the SQL query that filtersby the user's ID or username. Example >>> SELECT * FROM table WHERE user_id = '$user_id'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM