|
Posted by Michael Fesser on 07/23/07 04:18
..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
Navigation:
[Reply to this message]
|