Hi All!
I have a table with different kinds of customers information. With the code I have posted below, I want to pull out all the records from the database.
When I progress to make the "create_record" page, my intention is that it should automatically be added as an extra row to the table, as you can see below.
I have two records in the database, with some dummy info, just to check if my code was working. But I only get that one record out.
MY code is like this: I hope someone can see what I am dong wrong in my query, and cant hint my in the right direction on how to get all the records out this way :-)
<?php //Pull out the info from the database
$sqlCommand = "SELECT * FROM customers ORDER BY navn ASC LIMIT 1";
$result = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
$contactDisplay = '';
while ($row = mysqli_fetch_array($result)) {
$id = $row['id'];
$navn = $row['navn'];
$adresse = $row['adresse'];
$telefon = $row["telefon"];
$email = $row["email"];
$udmark = $row["udmark"];
$skind = $row["skind"];
$pris = $row["pris"];
$kontaktet = $row["kontaktet"];
$contactDisplay .= '<tr>
<td>' . $navn . '</td>
<td>' . $adresse . '</td>
<td>' . $telefon . '</td>
<td>' . $email . '</td>
<td>' . $udmark . '</td>
<td>' . $skind . '</td>
<td>' . $pris . '</td>
<td>' . $kontaktet . '</td>
</tr>';
}
mysqli_free_result($result);
?>
Further down the page I echo out the variable like this:
<div id="center">
<table width="867" border="1" cellspacing="5" cellpadding="5">
<tr>
<th width="85" scope="col"> Navn </th>
<th width="201" scope="col"> Adresse </th>
<th width="54" scope="col"> Telefon </th>
<th width="120" scope="col"> Email </th>
<th width="80" scope="col"> Udmark </th>
<th width="44" scope="col"> Antal </th>
<th width="74" scope="col"> Pris </th>
<th width="66" scope="col"> Kontaktet </th>
</tr>
<?php echo $contactDisplay; ?>
</table>