PHP / PDO echo data from database into a table

Ok so I have figured it out

$getUser = $db->prepare("SELECT * FROM users");
$users = $getUsers->fetchAll();

<?php foreach ($users as $user) { ?>
   <td><?php echo $users['username'] ?></td>
   <td><?php echo $users['password'] ?></td>
<?php } ?>

It now echo’s every username and password inside the table. even if I add new ones in the database I just hit refresh and they are added.

Sorry for writing my question in a confusing way.

Browse More Popular Posts

Leave a Comment