oliverj777 Posted August 27, 2010 Share Posted August 27, 2010 Basically, I have a database table called 'users' and I would like to populate a drop down box with these values of 'users'. How?? - to call upon the values is this: 'upduser2' Right now, all I am using is a text box, in where you have to type in the users name manually (this is so an admin can change variables and settings according to that current user). This is what I am using so far: <h3>Update User Level</h3> <? echo $form->error("upduser"); ?> <table> <form action="adminprocess.php" method="post"> <tr> <td> Username:<br /> <input type="text" name="upduser" maxlength="30" value="<? echo $form->value("upduser"); ?>" /></td> <td> Level:<br /> <select name="updlevel"> <option value="1">1 </option> //example settings <option value="9">9 </option> </select></td> <td><br /> <input type="hidden" name="subupdlevel" value="1" /> <input type="submit" value="Update Level" /></td> </tr> </form> </table></td> </tr> Much help would be appreciated. Quote Link to comment Share on other sites More sharing options...
lfernando Posted August 27, 2010 Share Posted August 27, 2010 Say your database is called "USERS" and you have fields like "username", you can populate the dropdown list with the values of "username" as follows: <?php $result = mysqli_query($link, 'SELECT * FROM users'); while ($row = mysqli_fetch_array($result)) { $users[] = array('username' => $row['username']); } ?> <form> <select name="users"> <?php foreach ($users as $user): ?> <option value="<?php echo $user['username']; ?>"> <?php echo $user['username']; ?></option> <?php endforeach; ?> </select> <form> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.