Quantcast
Channel: MySQL Forums - PHP
Viewing all articles
Browse latest Browse all 938

Connecting to a database and displaying 1 result (2 replies)

$
0
0
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);
?>

Viewing all articles
Browse latest Browse all 938

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>