Jump to content

while statement in drop down menu?


garyed

Recommended Posts

I'm having a problem with populating a second drop down menu that needs to be identical to the first from a mysql database.

I have about 20 items in the DB & I only want to show the first 9.

My code is:

      <select name="a_type" style="width: 175px;"> <option value="" selected="selected"> None selected</option> 
      <?php
$i=1;
while (($_produce = mysql_fetch_array($result_produce)) && ($i <=9 ))
{
$produce_type=$_produce["type"];
$produce_id=$_produce["id"];
$i++;
?>

<option value="<?php echo $produce_id; ?>"><?php echo $produce_id; ?> - <?php echo $produce_type; ?> </option>
<?php
}
?>
        </select>

 

That works fine in my first drop down menu but the second drop down menu with the same exact code will show items starting at 11 & higher

instead of 1 to 9. I haven't tried closing the DB & the reopening it which I assume would work but there are a lot of other variables & things I'd

have to check to make sure they don't get effected so I'd rather not.  Is there a simple way to solve this? 

 

Link to comment
Share on other sites

I appreciate the help but I've been messing with it all day & still haven't gotten it.

I can get the pointer back to whatever number I put in the argument but I just get that same number 8 times.

I even tried reset() & that helped a little populating the drop down but it locked up the database.

If  anyone could show me how to fix my code that would be greatly appreciated. 

 

Link to comment
Share on other sites

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.