> -----Original Message----- > From: Richard Lynch [mailto:ceo@xxxxxxxxx] > Sent: Monday, 2 May 2005 6:16 AM > To: Murray @ PlanetThoughtful > Cc: php-general@xxxxxxxxxxxxx > Subject: RE: 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). 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. For the project associated with contid 1, the entire list of contids in the project would be 1,2,3,6,8. So, my select query for that project should look like: "SELECT COUNT(*) FROM tbl_content_messages WHERE contid IN (1,2,3,6,8)" Using the association of contid between tbl_content and tbl_content_messages, that should return a total count of 5 messages for the project hierarchy that begins with tbl_content record with contid of 1. Similarly, the next project in tbl_content, with contid of 4, would be summarized by: "SELECT COUNT(*) FROM tbl_content_messages WHERE contid IN (4,5,7,9)" Again, from the pseudo recordsets above, that should return a message count of 6. So, in the two functions from my original message I'm trying to build the IN list of contid values for each of the projects. In the page that calls the functions, I pull a recordset of all records in tbl_content that have no parid (and thus, by definition, are projects). Using a while loop, I move through the project recordset and for each record in it I have "$leaflist = listProjectChildren($contid);". In the example above, for the project contid of 1, I am hoping to return from listProjectChildren() a variable that contains the value '1,2,3,6,8', so that this can be used in a SELECT COUNT(*) query using the IN operator to count all messages that are attached at any level in the project hierarchy underneath contid 1. I know this is probably needlessly convoluted, but I inherited this table structure from another developer and I'm trying to make sense of it in some way. Hope that explains a little better what I'm going on about. Thanks again, Murray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php