I wanted to know, if you have a smarter solution:
<table>
<thead>
<tr>
<th>Person</th>
<th>Country</th>
<th>Colors</th>
<th>Number</th>
</tr>
</thead>
<tbody>
<?php
$pdo = Database::connect();
$sql = "SELECT * FROM people ORDER BY timestamp ASC;" ;
foreach ($pdo->query($sql) as $row) {
$person = $row['person'];
echo '<tr> ';
echo('<td>'.$person.'</td>');
echo('<td>'.$row['country'].' </td>');
echo('<td>');
$sql2 = "SELECT * FROM features WHERE person = '$person' ORDER BY colors ASC;" ;
foreach ($pdo->query($sql2) as $row) {
echo($row['colors'].'<br>');
}
echo('</td>');
echo('<td>'.$row['Number'].' </td>');
echo '</tr> ';
}
Database::disconnect();
</tbody>
</table>
So what I wish to achieve, in one row I want to display all colors of my table featuresthat have the same person name than my table people:
Person Country Colors Number
===================================
Tom France red 12
green
blue
I know the way I did it is not a good way, but I don't know how to do it in another way. Because in the way I solved it, I get the following result:
Person Country Colors Number
===================================
Tom France red
green
blue