I am trying to take the following rows
username | id | role
SELECT u.username, u.id, r.role FROM ".TBL_USERS." u
INNER JOIN ".TBL_ADMIN_ROLES." r ON r.userid = u.id
WHERE u.userlevel > 3
At the moment, I use the following code to get the results.
<?php
$q = $database->getAllAdmins();
while($row=mysql_fetch_assoc($q))
{
?>
<a class="main" href="profile.php?id=<? echo $row['id']; ?>"><? echo $row['username']; ?></a>
<ul>
<li><? echo $row['role']; ?></li>
</ul>
<?
}
?>
Obviously, this is looping through and showing the username over and over.
What I want it to do is show the username once and then show every role below.
Any ideas? Thanks 🙂
My answer is the same concept as the others, just cleaner.