Jump to content

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.