YsoL8
YsoL8

Reputation: 2214

Looping though a while statement

I have a sequence of mysql query result resources stored in a array.

E.G array([0] => resource [1] => resource ...ect);

This code retrieves the first resource in the array:

$third_count = "0";
while ($user_result = mysql_fetch_array($user[$third_count])) {
print_r($user_result);
}
$third_count = $third_count +1;

I'm just stuck trying to find an if statement that'll loop though the array.

Something like: while ($third_count =< $second_count) is what I need, but it doesn't seem to work.

Where $second count is the number of elements in the array.

Thanks for pointers!

Upvotes: 0

Views: 68

Answers (1)

Buggabill
Buggabill

Reputation: 13921

What you want to do is use a foreach loop to loop through that array of result resources. Counts will not matter then.

foreach($resourcearr as $res) {
    while ($user_result = mysql_fetch_array($res)) {
        print_r($user_result);
    }
}

Upvotes: 1

Related Questions