I have a database with a login table. I am trying to populate a dropdown menu that lists all the usernames from the username field in the login table for a private messaging system that I have.
i have tried an attempt at this but know it's completely wrong..
<?php
include './template/connect.php';
$query = "SELECT username FROM login";
mysql_query($query);
$query = mysql_query('SELECT * FROM login');
if(mysql_error())
{
print(mysql_error());
}
while($row = mysql_fetch_array($query))
echo'<select name="select">';
{
echo'<option value="'.$row[username].'">'.$row[username].'"</option>';
}
echo'</select>';
?>
any help to list all the usernames in a dropdown would be great. thank you.