Hi everyone. I have some code that i have a little problem with.....
I am trying to make a drop down menu that populates its self from an mysql database. I have it populating the menu but alot of it is duplicate content.
It is selecting the country. So say people are irish and there are 5 irish people in the db it shows ireland 5 times. Is there any way around this..
Here is the code i am using
PHP Code:
<?php
// Include our login information
include('dbloginDetails.php');
// Connect
$connection = mysql_connect( $db_host, $db_username, $db_password );
if (!$connection)
{
die ("Could not connect to the database: <br />". mysql_error());
}
// Select the database
$db_select=mysql_select_db($db_database);
if (!$db_select)
{
die ("Could not select the database: <br />". mysql_error());
}
// Assign the query
//$query = "SELECT * FROM `entrants` WHERE country = 'ireland' AND postcode = '7'";
$query = "SELECT * FROM `entrants` ";
//$query = "SELECT * FROM `entrants`";
// Execute the query
$result = mysql_query( $query );
if (!$result)
{
die ("Could not query the database: <br />". mysql_error());
}
?>
<div align="center">
<form name="form1" method="post" action="readingdatabase.php">
<select name="country" id="country">
<?php
// Fetch and display the results
while ($result_row = mysql_fetch_row(($result)))
{
echo '<option>' .$result_row[9] . '</option>';
}
//Close the connection
mysql_close($connection);
?>
</select>
<p align="center"><input type="submit" name="Submit" value="Submit Form"></p></td>
</form>
</div>