SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Looping through another looping

    I made a drop down menu and am trying to edit it but it only loops 1 times
    PHP Code:
    <?php 
    do{?>
    <tr>
     <td>

    <select name="unit[]" id="unit">
                                                    <option value="0">select</option>
    <?php 
    do{?>
                                                        <option value="<?php echo $row_container_unit['id'];?>
    <?php if($row_container_unit['id']==$row_inland_operation['id'])            {?>selected='selected'<?php }?>>

    <?php echo substr($row_container_unit['name'],0,20);?>                    </option>
    <?php }while($row_container_unit mysql_fetch_assoc($container_unit));?>
    </select>
     </td>
    </tr>
     <?php }while($row_inland_operation=mysql_fetch_assoc($inland_operation));?>

    So its only giving me the first value
    but it doesn't show me the rest
    any help????

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Are $container_unit and $inland_operation assigned to valid result resources with unfetched rows in them?

  3. #3
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    am using those statements at the top:
    PHP Code:
    $query_container_unit="select * from container_unit";
    $container_unit mysql_query($query_container_unit) or die(mysql_error());
    $row_container_unitmysql_fetch_assoc($container_unit);

    $query_inland_operation="select * from inland_operation inl , container_unit cn where oper_id='".$operation_id."' and inl.unit=cn.id";
    $inland_operation mysql_query($query_inland_operation) or die(mysql_error());
    $row_inland_operationmysql_fetch_assoc($inland_operation); 

  4. #4
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what am thinking
    that we cant use the do while statement with the same name more than once right??

    but how can i loop through the options again??

  5. #5
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Take a look at mysql_data_seek, resets the pointer of a result set to the beginning so you can reuse it on the same script.

  6. #6
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh thank you
    i put mysql_data_seek($result, 0);
    an the end of my inside loop
    and it works fine now
    Thankss again


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •