0

I am working on having a php site which has register/login functionality that then has a page to display all users and their information, and then another page that displays teams which anyone can join with the click of a button.

I am currently stuck with looping the users table and displaying all users 'battletags' which is pretty much a username.

I previously used foreach($rows as $row) etc but am not sure how to implement it with this project. I am quite new to php so not sure which variables should be going in the loop.

I have been able to display the logged in user's battletag with this php

Welcome  <?php print($userRow['user_name']); ?> <br>
Rank <?php print($userRow['user_rank']); ?><br>
<a href="players.php">Players</a>

I want to be able to loop through every single user in the database and display their battletag, how would I go about this.

Dannad
  • 151
  • 1
  • 10

1 Answers1

0

If you have all your users in an array named $users, you could use this syntax.

<?php foreach ($users as $userRow) : ?>
    Welcome  <?= $userRow['user_name'] ?> <br>
    Rank <?= $userRow['user_rank'] ?><br>
    <a href="players.php">Players</a>
<?php endforeach ?>
user2182349
  • 9,569
  • 3
  • 29
  • 41