|
Posted by Norman Peelman on 07/23/07 10:32
Michael Fesser wrote:
> .oO(zach)
>
>> Yes, it worked great, except I had to add array_pop() after the loop
>> like this:
>>
>> while ($query_1_data[] = mysql_fetch_arrray(...))
>> {
>> }
>>
>> array_pop($query_1_data);
>>
>> because it left the last element of the array blank, and with six arrays
>> I was ending up with 6 blank elements when I merged them, but now it
>> works great.
>
> You can drop array_pop() if you do the looping and assignment properly.
> mysql_fetch_*() will return FALSE if there are no more values left in
> the result set. The code above still appends that FALSE value to the
> array, which you have to remove afterwards. Consider that bad style.
>
> Better:
>
> while ($record = mysql_fetch_array(...)) {
> $query_1_data[] = $record;
> }
>
> With the last return from mysql_fetch_array() the loop will terminate,
> before appending the FALSE to the array. So there's no need for an
> array_pop() anymore.
>
> Micha
If that's the case then cool... i've never run into that problem
before, that I can recall.
Norm
[Back to original message]
|