define("MAX_GEN",5); function detail($number) { $d = mysql_query("select * from table where number = '$number'"); if(mysql_num_rows($d) == 0) { $p[name] = "N/A"; $p[number] = "N/A"; $p[m_number] = "N/A"; $p[f_number] = "N/A"; } else $p = mysql_fetch_assoc($d); return $p; } function gen($number, $generation = 0, $out) { if ($generation >= MAX_GEN) { return false; } $record = detail($number); if ($generation == 0) $out[0][] = $record; // first man $generation++; // next generation if (!$out[$generation] && ($generation != MAX_GEN)) $out[$generation] = array(); $x_mother = gen($record[m_number], $generation ); // continue with mother $x_father = gen($record[f_number], $generation ); // continue with father if ($out[$generation]) { $out[$generation][] = $x_mother; $out[$generation][] = $x_father; } return $out; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter