Read Row In Database Function

PHOTO EMBED

Sun Apr 02 2023 21:02:49 GMT+0000 (Coordinated Universal Time)

Saved by @Joe_Devs #php #mysql

function readAll(){
  // Connect to db
    global $connection;
  // make result global so you can use it in the other file
    global $result;

    $query = "SELECT * FROM USERS";

    $result = mysqli_query($connection, $query);
}


// HTML FILE
<?php
readAll();
while ($row = mysqli_fetch_assoc($result)){
?>

<pre>
    <?php
    print_r($row);
    }
    ?>
</pre>
content_copyCOPY