Advertisement
Skorpius

Generate Buttons on Condition

Jun 22nd, 2022
1,198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. //Call your connection script - Require_once or include_once
  2. //Generate buttons for those users with a status of zero (unverified)
  3.  
  4.     function statusZero($pdo){
  5.        
  6.         $status = 0;
  7.         $sql = "SELECT id FROM users WHERE status = ? ";
  8.         $stmt = $pdo->prepare($sql);
  9.         $stmt->bindParam(1,$status);
  10.         $stmt->execute();
  11.         $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
  12.  
  13.         foreach($rows as $val){
  14.             echo "<button class='btn' type='submit' name='mybutton' id='{$val['id']}' value='{$val['id']}'>{$val['id']}</button>" . " | ";
  15.         }
  16.        
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement