PHP outputs mysqli row values outside while loop -


i trying output row values outside while loop this

$sql = mysqli_query($connection, "select username accounts rank='admin'");           while($row = mysqli_fetch_array($sql)) {             $username = $row['username'];           }    

i output , print result outside while loop. tried print_r doesn't seem work, shows last or first value not all.

you need save each value in array inside of while loop.

while($row = mysqli_fetch_array($sql)){   //save in array   $username[] = $row['username']; }  //output values print_r($username); 

you need brackets [] save each value array. $username[]


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -