Hi im new to frontend world and i made a small sql database filled with some data , i could get the data from database to my php code as Associative Array but the problem is that i cant fill them inside my table , they appear upper and outside the table. with any help i'll be thankful.
<?php
include("page.html");
include("databaseConnection.php");
$sth = $conn->prepare("SELECT ID, userName from passwords");
$sth->execute();
$result[] = $sth->fetchAll();
if(isset($_POST["showData"])){
echo "<table style='border: 2px solid black'>
<tr>
<th style='border: 1px solid red'>ID</th>
<th style='border: 1px solid black'>User Name</th>
</tr> <tbody>";
foreach ($result as $key => $value) {
foreach ($value as $key1 => $value1) {
echo "<tr>
<td>".print_r($value1['ID'])."</td>
<td>".print_r($value1['userName'])."</td>
</tr>";
}
}
echo "</tbody></table>";
}
?>