Reply to RE: [PHP] Problem with array

Your name:

Reply:


Posted by Richard Lynch on 05/02/05 04:15

On Sun, May 1, 2005 1:46 pm, Murray @ PlanetThoughtful said:
>> -----Original Message-----
>> From: Richard Lynch [mailto:ceo@l-i-e.com]
>> Sent: Monday, 2 May 2005 6:16 AM
>> To: Murray @ PlanetThoughtful
>> Cc: php-general@lists.php.net
>> Subject: RE: [PHP] Problem with array
>>
>> On Sun, May 1, 2005 1:08 pm, Murray @ PlanetThoughtful said:
>> > Color me confused. I removed "global $arrtree;" and added "$arrtree =
>> > array();" to the function buildProjectTree() and now the parent
>> function
>> > (listProjectChildren) returns no values at all.
>> >
>> > I've checked the page from which listProjectChildren() is being
>> called,
>> > and
>> > $arrtree does not appear as a variable in it at all, so it seems
>> "global
>> > $arrtree;" was doing SOMETHING, but at this point I have no idea what.
>> >
>> > Still trying to work this out, if anyone else has any suggestions?
>>
>> I'm not real clear on what you are trying to do in the first place, but
>> if
>> taking out the global messed up, put it back :-)
>>
>> Maybe add another global $arrtree in the other function so *BOTH*
>> functions are using the same $arrtree?
>
> (Laugh) It's probably because I'm not explaining myself well... Let me try
> to outline pseudo recordsets for the 2 tables:
>
> Tbl_content:
>
> Contid, parid
> 1,
> 2,1
> 3,1
> 4,
> 5,4
> 6,1
> 7,5
> 8,2
> 9,7
>
> Tbl_content_messages:
>
> Msgid, contid
> 1,2
> 2,2
> 3,4
> 4,5
> 5,5
> 6,5
> 7,6
> 8,6
> 9,8
> 10,9
> 11,9
>
>
> Okay, so what I'm trying to do is display a summary count of all of the
> messages in tbl_content_messages for each project in tbl_content (in this
> case the 2 records with contid of 1 and 4, as they have no parid value).

Okay, I'm lost.

You're tossing around words like project, but you've got a field contid
and parid, and I read this three times and I don't know which is which.

What's a cont?
What's a par?

I assume Msg is short for message.

Type them out. Your fingers may hurt today, but your brain will thank you
tomorrow. :-)

> The only way I could think to do this was to create a query that did a
> SELECT COUNT(*) from tbl_content_messages using the IN operator with a
> list
> of all of the contid values associated with each project.

I think you maybe want LEFT OUTER JOIN to keep the projects with 0 messages.

--
Like Music?
http://l-i-e.com/artists.htm

[Back to original 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

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