Jump to content

[SOLVED] Populating drop down box from database


ashrobbins87

Recommended Posts

I'm getting very frustrated with this, I've searched all over for a solution for this, with differing responses. I want a list of names from a database to populate a drop down list. The code I have at the moment is....

 

$getUsers_sql ="SELECT id, firstname FROM cms_users";

$getUsers_res = mysqli_query($mysqli, $getUsers_sql)or die(mysqli_error());

$getUsers_sql ="SELECT id, firstname FROM cms_users";
$getUsers_res = mysqli_query($mysqli, $getUsers_sql)or die(mysqli_error()); 

echo '<select name="users">'; 
while ($row = mysqli_fetch_assoc($result)) 
{ 
    echo '<option value="' . $row['id'] . '">' . $row['firstname'] . '</option>'; 
} 
echo '</select>';

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.