[PHP-DB] Nestling Array in PHP from MySql

2008-04-09 Thread A. Joseph
Well i need a little ideal on nestling this php array.

This what i want to do.

Have you heard of online clubing? http://www.disneytreasures.biz/

This how it works,

1) (*Agent*) You bring 3 persons (first you as an agent or officer)

2) The 3 person you brought, brings 3 persons each

3) Again each persons under those 3 persons bring 3 persons again, on and on

So, how can i caculate the total persons under you (*the Agent)*

i want to use MySql database, or can you help me with the table structure?

The ideal is like Clubfreedom. and if you see any tutorial on this, please
help me with the link.

Any ideal will be helpful.


[PHP-DB] Re: php-db Digest 9 Apr 2008 13:17:18 -0000 Issue 4019

2008-04-09 Thread A. Joseph
The question is.

Some nestled calculation.
How did club freedom did the calculation, or how will the database structure
looks like?

*The example is -: *

*Joseph* gave birth to *John*, *James,* and *Johnson*
*John* gave birth to* Peter*, *Matter*, and *Potter*
James gave birth to Juliana, Justin, and *Jane*
Johnson gave birth to Jak, Jake and Jacob

Continuously like that,
Peter the son of John also gave birth to another 3 children
And the 3 children also keep giving birth to 3 children each,  so
How can I calculate the Total descendants of Joseph?
How can I calculate the total   descendants of John or any of the grand
children?

Because each of the children also start having grand children, while Joseph
grand descendants increases.

I want to use MySql/PHP
The concept is Like http://www.disneytreasures.biz/ or ClubFreedom

All I want to do is to know who bring who?


[PHP-DB] Re: php-db Digest 9 Apr 2008 13:17:18 -0000 Issue 4019

2008-04-09 Thread A. Joseph
The question is.

Some nestled calculation.
How did club freedom did the calculation, or how will the database structure
looks like?

*The example is -: *

*Joseph* gave birth to *John*, *James,* and *Johnson*
*John* gave birth to* Peter*, *Matter*, and *Potter*
James gave birth to Juliana, Justin, and *Jane*
Johnson gave birth to Jak, Jake and Jacob

Continuously like that,
Peter the son of John also gave birth to another 3 children
And the 3 children also keep giving birth to 3 children each,  so
How can I calculate the Total descendants of Joseph?
How can I calculate the total   descendants of John or any of the grand
children?

Because each of the children also start having grand children, while Joseph
grand descendants increases.

I want to use MySql/PHP
The concept is Like http://www.disneytreasures.biz/ or ClubFreedom

All I want to do is to know who bring who?


Re: [PHP-DB] Re: php-db Digest 9 Apr 2008 13:17:18 -0000 Issue 4019

2008-04-09 Thread Daniel Brown
On Wed, Apr 9, 2008 at 5:09 PM, A. Joseph [EMAIL PROTECTED] wrote:
 The question is.

  Some nestled calculation.
  How did club freedom did the calculation, or how will the database structure
  looks like?

  *The example is -: *

  *Joseph* gave birth to *John*, *James,* and *Johnson*
  *John* gave birth to* Peter*, *Matter*, and *Potter*
  James gave birth to Juliana, Justin, and *Jane*
  Johnson gave birth to Jak, Jake and Jacob

Using a parent-child relationship, exactly as in nature.

MySQL:
db_name.people
id INT ( 8 ) AUTO_INCREMENT NOT NULL
full_name VARCHAR ( 255 )
child_of INT ( 8 ) NOT NULL
num_children INT ( 2 ) NOT NULL

Then do some simple queries like this:
?php
// First record
$sql = INSERT INTO people(full_name,child_of,num_children)
VALUES('.$fullName.','0','0');

// For each child
// $parentID is the `id` column for the record of the parent of this child.
$sql = INSERT INTO people(full_name,child_of,num_children)
VALUES('.$fullName.','.$parentID.','0');
$sql = UPDATE people SET num_childen=(num_children + 1) WHERE
id='.$parentID.';
?

And so forth.  Code sanity and such are your responsibility, but
that should kick-start the idea for you.

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php