Jump to content

[SOLVED] Dynamic Drop Down Menu Code Problem


kyleldi

Recommended Posts

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 :)

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.