Skip navigation links

MySQL Forums :: PHP :: Connecting to a database and displaying 1 result


Advanced Search

Connecting to a database and displaying 1 result
Posted by: Chris Harris ()
Date: March 08, 2013 05:19AM

I have been working on a code to establish conenction to a database to to retrieve the information on the database. The database contains a list of names and a colour code next to them.

I have connected to the database and can pull the information but it does not limit the number of rows that is being returned (it shows all the entries).

Can anyone look at my code and help me with something that is clearly missing???!?! The FirstName entries are all unique so I only need to check the name with the color code.

<?php
$con=mysqli_connect("localhost","####","####","####");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM Members");

while($row = mysqli_fetch_array($result))
{
echo $row['FirstName'] . " " . $row['Level'];
echo "<br />";
}

mysqli_close($con);
?>

Options: ReplyQuote


Subject Written By Posted
Connecting to a database and displaying 1 result Chris Harris 03/08/2013 05:19AM
Re: Connecting to a database and displaying 1 result Peter Brawley 03/08/2013 11:52AM
Re: Connecting to a database and displaying 1 result Hassan Ahmed 03/09/2013 03:32AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.