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>

Further down the page I echo out the variable like this:

<div id="center">
<table width="867" border="1" cellspacing="5" cellpadding="5">
    <th width="85" scope="col">&nbsp;Navn&nbsp;</th>
    <th width="201" scope="col">&nbsp;Adresse&nbsp;</th>
    <th width="54" scope="col">&nbsp;Telefon&nbsp;</th>
    <th width="120" scope="col">&nbsp;Email&nbsp;</th>
    <th width="80" scope="col">&nbsp;Udmark&nbsp;</th>
    <th width="44" scope="col">&nbsp;Antal&nbsp;</th>
    <th width="74" scope="col">&nbsp;Pris&nbsp;</th>
    <th width="66" scope="col">&nbsp;Kontaktet&nbsp;</th>
  <?php echo $contactDisplay; ?>                         
6 Years
Discussion Span
Last Post by joban.ali

Haha Thanks man!!

Just to be diffucult:

When would you write "LIMIT 1"?

In what situation is that the right thing to use with the rest of your query?

Im new to this, so I tend to sometimes make some funny queries...


Iv been there and still am, it can be used in all sorts of situation, i use it for login where i know and expect the query to result should be 1 or nothing, or general limiting the amount of the time the database has to go through a loop to display certain information.

I am all so fairly new to so maybe someone else can give a more detailed reply

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.