kyleldi Posted August 15, 2007 Share Posted August 15, 2007 Hi everyone, I'm working on a dynamic drop down menu that I've got on a form. For some reason if there is more then one row in the output (such as two different jobs), my code is creating two seperate drop down menus, one for each job. Any idea what I've done wrong? Here's my code... <?php do { ?> <tr> <td><select name="PositionApplyingFor" id="PositionApplyingFor"> <option value="Null">- Please Choose A Job -</option> <option value="<?php echo $row_rs_jobs['Job']; ?>"><?php echo $row_rs_jobs['Job']; ?></option> </select> </td> <td colspan="3"> </td> <td> </td> </tr> <?php } while ($row_rs_jobs = mysql_fetch_assoc($rs_jobs)); ?> Any help would be appreciated Link to comment https://forums.phpfreaks.com/topic/65094-solved-dynamic-drop-down-menu-code-problem/ Share on other sites More sharing options...
lemmin Posted August 15, 2007 Share Posted August 15, 2007 You are looping through each row and creating a drop down menu. If there is ever more than one row, it will create a new drop down menu. You can change it by moving the select tags outside the loop, something like this: <tr> <td><select name="PositionApplyingFor" id="PositionApplyingFor"> <option value="Null">- Please Choose A Job -</option> <?php do { ?> <option value="<?php echo $row_rs_jobs['Job']; ?>"><?php echo $row_rs_jobs['Job']; ?></option> <?php } while ($row_rs_jobs = mysql_fetch_assoc($rs_jobs)); ?> </select> </td> <td colspan="3"> </td> <td> </td> </tr> Link to comment https://forums.phpfreaks.com/topic/65094-solved-dynamic-drop-down-menu-code-problem/#findComment-324861 Share on other sites More sharing options...
kyleldi Posted August 15, 2007 Author Share Posted August 15, 2007 Worked like a charm.. thanks so much for the help! Link to comment https://forums.phpfreaks.com/topic/65094-solved-dynamic-drop-down-menu-code-problem/#findComment-324863 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.