Free2Code
 
Time: 2008-11-21, 04:45am
Nestled Array calculation.
Subject: Nestled Array calculation.  ·  Posted: 2008-04-10, 01:39am
Rank: ? (60)
Member #: 22843
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?

Joseph

 
  Reply to this ·  Post link ·  Top
Subject: Re: Nestled Array calculation.  ·  Posted: 2008-04-11, 05:51am
Rank: ? (767)
Member #: 11085
Seems a simple quadratic formula. I would guess in the form y = Ax^3+Bx^2+Cx, just plug in some numbers to find A, B, and C. X is the number of generations, y is the number of people.

» Post edited 2008-04-11, 05:51am by relpats_eht.

- relpats_eht
 
  Reply to this ·  Post link ·  Top
Subject: Re: Nestled Array calculation.  ·  Posted: 2008-05-06, 12:42pm
Rank: ? (60)
Member #: 22843
Well, so far i have made it work but with another format, i got a class from phpclasses.org

The only problem i`m having now is the HTML display, i have been thinking one million ways to display it.

The return is an Array that looks like this
Code:
  1. Array
  2. (
  3.     [0] => Array
  4.         (
  5.             [0] => 1009603
  6.             [section_id] => 1009603
  7.             [1] => 4
  8.             [section_left] => 4
  9.             [2] => 11
  10.             [section_right] => 11
  11.             [3] => 1
  12.             [section_level] => 1
  13.             [4] => Joseph Abah
  14.             [section_name] => Joseph Abah
  15.         )
  16.     [1] => Array
  17.         (
  18.             [0] => 1009956
  19.             [section_id] => 1009956
  20.             [1] => 5
  21.             [section_left] => 5
  22.             [2] => 8
  23.             [section_right] => 8
  24.             [3] => 2
  25.             [section_level] => 2
  26.             [4] => Onuche Mikel
  27.             [section_name] => Onuche Mikel
  28.         )
  29.     [2] => Array
  30.         (
  31.             [0] => 1005539
  32.             [section_id] => 1005539
  33.             [1] => 9
  34.             [section_left] => 9
  35.             [2] => 10
  36.             [section_right] => 10
  37.             [3] => 2
  38.             [section_level] => 2
  39.             [4] => Owen Joncena
  40.             [section_name] => Owen Joncena
  41.         )
  42. )


so the Array are grouped in level.
so i want to display all level 1 or a different row then
level 2 on a different row.

Thank you

» Post edited 2008-05-06, 12:42pm by joefazee.

 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

icons