Hey guys, so, I'm creating a control panel for my site where I can edit user's priveledges etc. What I'm trying to do is populate a drop down list of usernames in the database to select from.
This is what I've got so far (it's one continuous chunk so I spaced it out for easier reading):
<?php
define('DB_NAME', 'removed');
define('DB_USER', 'removed');
define('DB_PASSWORD', 'removed');
define('DB_HOST', 'localhost');
?>
<select name="username" id="username">
<option value="">--</option>
<option value="
<?php
$database_link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$db = mysql_select_db(DB_NAME, $database_link);
$loop = mysql_query("SELECT * FROM registration");
while($row = mysql_fetch_array($loop)) { echo($row['username']); }
?>">
<?php
$database_link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$db = mysql_select_db(DB_NAME, $database_link);
$loop = mysql_query("SELECT * FROM registration");
while($row = mysql_fetch_array($loop)) { echo($row['username']); }
?>
</option>
</select>
At the moment it returns the usernames but only in a single option box with all the names bunched together.
Thanks :)