Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

So this is extremely basic simple stuff. I'm having a little bit of an issue with it here. I don't know if I'm overlooking something here.

<?php
while ($supps = tep_db_fetch_array($suppliers_select))
{
    echo"
        <tr class='dataTableHeadingRow'>
            <td class='dataTableHeadingContent'>$supps[entry_company]</td>
        </tr>
    ";

    echo"
        <tr class='dataTableHeadingRow'>
            <td class='dataTableHeadingContent'>Status</td>
            <td class='dataTableHeadingContent'>Current Timestamp</td>
            <td class='dataTableHeadingContent'>Change Timestamp</td>
        </tr>";

    while ($grab_teh_statuses = tep_db_fetch_array($grab_statuses))
    {
        echo"
            <tr class='dataTableRow'>
                <td class='dataTableContent'>
                    $grab_teh_statuses[orders_status_name]
                </td>
                <td class='dataTableContent'>
                    $grab_teh_statuses[time_stamp]
                </td>
                <td class='dataTeableContent'>

                </td>
            </tr>
        ";
    }
}
?>

As you can see, there is a parent While loop and nested inside that While loop there is another While loop. Everything is getting pulled from the database correctly and being populated. The problem I'm running into is the nested While loop only loops once. Wouldn't it loop over and over as many times as the parent While loop goes around?

share|improve this question
    
No, it would loop enough times to fulfil all the values of $grab_statuses, for each iteration of the parent loop. –  ʰᵈˑ Sep 17 '14 at 19:36
    
it'll be EXECUTED as many times as the parent loop does, but it'll only iterate however many items are returned by the teb_db_fetch_array() call –  Marc B Sep 17 '14 at 19:37

1 Answer 1

up vote 1 down vote accepted

Wouldn't it loop over and over as many times as the parent While loop goes around?

There's nothing to reset the $grab_statuses cursor, so in the second and subsequent iterations of the outer loop, the inner loop finishes immediately because there are no more records to fetch.

share|improve this answer
    
Thanks for the clarification. I sorted it out. –  0cean_ Sep 17 '14 at 20:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.