funbinod Posted March 7, 2014 Share Posted March 7, 2014 how to make a dropdown menu on a FORM with the datas from a column of a database table like items from all rows of a "MEMBERS" table's "NAME" column Link to comment Share on other sites More sharing options...
justsomeguy Posted March 7, 2014 Share Posted March 7, 2014 You select the data from the database, and loop through each record to write out the HTML for the select options. Link to comment Share on other sites More sharing options...
es131245 Posted March 7, 2014 Share Posted March 7, 2014 (edited) Easy. foreach($users as $u){print('<input type="radio" name="username" value="'.$u.'">'.$u.'<br>');} Drop down is CSS finish off. Edited March 7, 2014 by es131245 Link to comment Share on other sites More sharing options...
funbinod Posted March 23, 2014 Author Share Posted March 23, 2014 i created loop for selecting from all the rows of a table like this--- <?$rows = mysql_num_rows($result);for ($n = 0 ; $n < $rows ; ++$n) { echo '' . mysql_result($result,$n,'item') . '<br />'; }?> but couldn't insert it into a dropdown list. please guide... Link to comment Share on other sites More sharing options...
funbinod Posted March 23, 2014 Author Share Posted March 23, 2014 tried to put in dropdown menu like this ---- echo '<form action="#" id="test" name="test">';echo '<select name="item">';echo "<option></option>";echo "<option>";{echo '' . mysql_result($result,$n,'item') . '<br />';}echo "</option>";echo '</select>';echo '</form>'; but returned error "Warning: mysql_result(): Unable to jump to row 2 on MySQL result index 5 in .................................." Link to comment Share on other sites More sharing options...
Steven Posted March 24, 2014 Share Posted March 24, 2014 This is what I did: <label>Client:</label> <?php $result = mysqli_query($con,"SELECT * FROM clients"); echo "<select name='clientid'>"; while ($row = mysqli_fetch_array($result)) { echo "<option value='" . $row['id'] . "'>" . $row['name'] . "</option>"; } echo "</select>"; ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now