Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Query looks at table for users with Yes in the logged_in column
- //which means they are logged in and gives the usernames.
- require("connect/connect.php");
- //Function to get all usernames that are online
- function usersOnline($pdo){
- $online = 'Yes';
- $query = ("SELECT username FROM users WHERE logged_in = ?");
- $stmt1 = $pdo->prepare($query);
- $stmt1->bindParam(1,$online);
- $stmt1->execute();
- $rows = $stmt1->fetchAll(PDO::FETCH_ASSOC);
- foreach($rows as $val){echo "{$val['username']}". " ";}
- }
- //To call the function - <?php usersOnline($pdo); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement