Connecting to a database and displaying 1 result
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);
?>
Subject
Written By
Posted
Connecting to a database and displaying 1 result
March 08, 2013 05:19AM
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.