tags:

views:

34

answers:

1

Hi

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!

+1  A: 

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);
    }
}
Buggabill
I thought of doing it like that, but I wasn't certain result resources (as opposed to normal arrays) could be used like that.
YsoL8
It is a normal array. It is just an array of resources.
Buggabill