Hello, I need some help, i have been trying at this for days and found no possible way. I have a drop down: <select name="payMethod" tabindex="10"> <option value="AlertPay">AlertPay</option> <option value="Check">Check</option> <option value="PayPal">PayPal</option> </select> HTML: I know Drop Downs cannot hold values like an input box. So what i need help with is how to get the selection drop down to hold a value from the database. Please help as i have been trying this for days. Thank you very much for you time, it is much appreciated. Michael
Basically i am creating an Edit Account page. I need that selection box to hold a value. Thanks, Michael
echo '<select name="yada">'; $query = mysql_query("SELECT * FROM categories"); if (mysql_num_rows($query) > 0) { while ($list = mysql_fetch_array($query)) { echo '<option value="'.$list['name'].'">'.$list['name'].'</option>'; } } else { echo '<option value="">There are no selection options.</option>'; } echo '</select>'; PHP:
(if I understood your question correctly) after you assign dbvalue : <select name="payMethod" tabindex="10"> <option value="AlertPay" <?php if (db_value=="AlertPay") echo ("selected=selected"); ?> >AlertPay</option> <option value="Check" <?php if (db_value=="Check") echo ("selected=selected"); ?> >Check</option> <option value="PayPal" <?php if (db_value=="PayPal") echo ("selected=selected"); ?> >PayPal</option> </select>
I think i explained it wrong to you. I need it to maintain there value what they made prior to Sign up. Say they selected PayPal in the database, it will then have PayPal selected in the drop down among all the others. Thank you any way, Michael
You need to render selected attribute when rendering inside the for loop. Final output would be: <select name="payMethod" tabindex="10"> <option value="AlertPay">AlertPay</option> <option value="Check">Check</option> <option selected="selected" value="PayPal">PayPal</option> </select> Code (markup):