my task at he moment is to show the data from a sql db in a browser. My code is fine for that, but now i have more and bigger sql tables and i am looking for a way to read and show it more dynamic. So that i dont have to write all the names of the column (the echo statements, if i have 100 columns it would not really work like this) in the code. Is there ab better way in this case?
Thanks.
<?php
error_reporting(E_ALL);
$db_link = mysqli_connect (MYSQL_HOST,
MYSQL_BENUTZER,
MYSQL_KENNWORT,
MYSQL_DATENBANK);
if ( $db_link )
{
echo('<p> Verbindung vorhanden: </p>');
}
else
{
echo('<p style="color:red"> Keine Verbindung vorhanden: </p>');
}
$db_res = mysqli_query($db_link, "SELECT AA, B1, C3 FROM tableXYZ")
or die("Fehler: " . mysqli_error());
echo("<table>");
while($row = mysqli_fetch_array($db_res))
{
echo("<tr>");
echo("<td>" . $row["AA"] . "</td>");
echo("<td>" . $row["B1"] . "</td>");
echo("<td>" . $row["C3"] . "</td>");
echo("</tr>");
}
echo("</table>");
?>