Skorpius

MySQLI Function with Array

Feb 5th, 2023
827
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. #MySQLi function using Array
  2.  
  3. function AdminUsersDetails1($dbc){
  4.        
  5.         $myArr=array();
  6.        
  7.         $sql = "SELECT first, last, email,status FROM adminusers;";
  8.        
  9.         $result = mysqli_query($dbc,$sql);
  10.  
  11.         $row_count = $result->num_rows;
  12.        
  13.         //echo $row_count;
  14.        
  15.         if($row_count !== 1){
  16.             echo "Error in query";
  17.         }
  18.        
  19.         $rows = array();
  20.        
  21.         $row = $result->fetch_assoc();
  22.        
  23.         $rows[] = $row["first"];
  24.         $rows[] = $row["last"];
  25.         $rows[] = $row["email"];
  26.         $rows[] = $row["status"];
  27.        
  28.         return $rows;
  29.                        
  30. }
Advertisement
Add Comment
Please, Sign In to add comment