I use two tables with an inner join on 'user.ID'='email.ID'.
Every user has a name and an ID. Each email has a username, the email address itself and a corresponding userID. It is possible for a user to have any amount of email addresses.
Usually i print out the results of my queries using:
$row["name"]
I select the data from the DB like this:
SELECT user.name AS name, user.ID as ID, email.user AS user, email.address AS address
FROM user INNER JOIN email ON user.ID=email.ID
I then display a table and output each user in one line.
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
<table>
.
.
.
while($row = mysqli_fetch_assoc($result)) {
<tr>
<td>$row["ID"]</td>
<td>$row["Name"]</td>
<td>$row["Email"]</td>
</tr>
}
}
//this snippet is shortened simplified because I use all HTML in php echoes
When I try to display the email adresses inside the corresponsing users result row I just get the user multiple times with a different email adress in every row.
What I want:
What I get:
How do I have to select/join/group the tables and columns and how do I output them correctly? Thanks for any help. I´ve been stuck here for days.
EDIT:
</div>