You are here: Re: PHP MYSQL QUESTION « All PHP « IT news, forums, messages
Re: PHP MYSQL QUESTION

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация