mraza Posted August 17, 2010 Share Posted August 17, 2010 hi i am in situation to display input box along with select option , here is my code <?php $run= $dbc->db("SELECT * FROM `table` WHERE `id`='$id'"); ?> <select name="service"> <?php while ($result = mysql_fetch_array($run)) { ?> <option value="<?php echo $result['id'] ; ?>"><?php echo $result['service'] ; ?></option> <?php // This is problem i need to get this as hidden field but it breaks my select options. ?> <input type="hidden" value="<?php echo $result['data'] ; ?>" name="data" /> <?php } ?> </select> so here i am stuck <input type="hidden" value="<?php echo $result['id'] ; ?>" name="data" /> when i repeat in while loop it breaks options box and display other options without in select box. any help please thanks Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted August 17, 2010 Share Posted August 17, 2010 Try storing the hidden fields in an array, then imploding them after you close the select box. <?php $run = $dbc->db("SELECT * FROM `table` WHERE `id`='$id'"); ?> <select name="service"> <?php $hidden = array(); while ($result = mysql_fetch_array($run)) { ?> <option value="<?php echo $result['id'] ; ?>"><?php echo $result['service'] ; ?></option> <?php $hidden[] = '<input type="hidden" value="'. $result['data'] . '" name="data" />'; } ?> </select> <?php echo implode("\n", $hidden); ?> Quote Link to comment Share on other sites More sharing options...
mraza Posted August 17, 2010 Author Share Posted August 17, 2010 Thank you very much sir for your help. its solved 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.