@@Dani
foreach($data as $row) {
foreach() hört sich so an, als könnte das Ganze durchaus eine Liste sein: ol oder ul außerhalb der Schleife; li darin.
echo ' <div class="gb-entry">
gb-entry hört sich so an, als wäre dafür article das richtige HTML-Element.
Was mir aber immer sauer aufstößt: wenn HTML-Tags mit echo erzeugt werden.
Nicht machen! Nicht HTML in PHP schachteln, sondern PHP in HTML – mit der alternativen Syntax für Kontrollstrukturen:
<?php foreach($data as $row): ?>
<article class="gb-entry">
<table>
<tr>
<th>
Von (User):
</th>
<td>
<?php echo htmlspecialchars($row['name']); ?>
</td>
</tr>
<tr>
<th>
Am:
</th>
<td>
<?php echo htmlspecialchars($row['datum']); ?>
</td>
</tr>
<tr>
<th>
Nachricht:
</th>
<td><p class="comment">
<?php echo nl2br(htmlspecialchars($row['kommentare'])); ?>
</p></td>
</tr>
</table>
</article>
<?php endforeach; ?>
Die notwendige Behandlung des Kontextwechsels (htmlspecialchars()) habe ich ebenso mit erledigt wie die Auszeichnung der Zeilenkopfzellen als th.
Statt <?php echo kann man auch die Kurzschreibweise <?= verwenden.
LLAP 🖖
--
“When UX doesn’t consider all users, shouldn’t it be known as ‘Some User Experience’ or... SUX? #a11y” —Billy Gregory
“When UX doesn’t consider all users, shouldn’t it be known as ‘Some User Experience’ or... SUX? #a11y” —Billy Gregory