Hi i want to print out the values of $row
in a table, i already have something but the output is not great. This is the code i have so far:
<?php
$sql = 'SELECT Titel FROM Algemeen ORDER BY Titel';
foreach ($pdo->query($sql) as $row) {
echo "
<table border='1'>
<tr>
<td>".$row['Titel']. "</td>"
"</tr>
</table>";
}
?>
So the table needs to be like this with a border
You should use it like below
<?php
$sql = 'SELECT Titel FROM Algemeen ORDER BY Titel';
echo "<table border='1'>";
foreach ($pdo->query($sql) as $row){
echo "<tr><td>".$row['Titel']. "</td></tr>";
}
echo "</table>";
Please have a look below snippet.
<?php
$sql = 'SELECT Titel FROM Algemeen ORDER BY Titel';
?>
<table border='1'>
<?php
foreach ($pdo->query($sql) as $row){
?>
<tr>
<td><?php echo $row['Titel'];?></td>
</tr>
<?php
}
?>
</table>
Or you can use <ul><li>
instead of <tr><td>
try this
<ul>
<?php foreach ($pdo->query($sql) as $row) {?>
<li> <?php echo $row['Titel'];?></li>
<?php }?>
<ul>