I have a table in my database like this:
IdUser | Name | Surname |
And another table with the following strucutre
IdPN | IdUser | PhoneNumber
The PK of this table is IdPN
, so each User can have more than one Phone number.
Now I'm getting the data from the first table for pupulating a table in my HTML page. I want something like this:
name | Surname| numbers |
_____|________|__________|
John | Doe | 21212121 |
| | 23424324 |
_____|________|__________|
Frank|Johnson | 23222111 |
| | 23747347 |
| | 36363636 |
_____|________|__________|
So the third colume can have more than one numbers.
The code php that I was using when I had just one number for each user, is the following:
<?php
$connectiondb->set_charset("utf8");
$query= "SELECT name, surname, phonenumber
FROM users";
if ($stmt = $connectiondb->prepare($query)) {
$stmt->execute();
$stmt-bind_result($nome,$cognome,$phonenumber);
while($stmt->fetch()){
echo '<tr>';
echo '<td>'.$nome.'</td>';
echo '<td>'.$cognome.'</td>';
echo '<td>'.$phonenumber.'</td>';
echo '</tr>';
}
$stmt->close();
?>
How I have to change my code for showing multiple number for each row of the table (user)?