\n"; echo " \n"; echo " \n"; echo "\n"; $p->output($depth); echo ""; // ---------------------------------------------- class Pedigree { var $_dog; var $_dogInfo; var $_ped; function Pedigree($dog) { $this->_dog=$dog; $this->_dogInfo=array(); $this->_ped=array(); $this->_getPedigree($dog); } function output($depth) { $url="http://$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]"; $span=$depth+1; echo "\n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; // OUTPUT PEDIGREE $colwidth=(int)(100/($depth+1)); for($r=0; $r\n"; for($c=0; $c<=$bb; $c++) { $rs=pow(2,$bb-$c); echo "\t\n"; } echo "\n"; } echo ""; echo "
\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " Number of generations to view: \n"; for ($i=3; $i<9; $i++) { if ($i==$depth) echo " $i \n"; else { $dog=$this->_dog; echo " $i \n"; } } echo " \n"; // get offspring information $query="select count(dog_id) from dogs where (dogs.sire=$dog or dogs.dam=$dog)"; $result=mysql_query($query); $row=mysql_fetch_array($result); $off=$row[0]; if($off==0) echo "No offspring found\n"; else { echo " "; echo " View offspring ($row[0] found)\n"; } echo "
\n"; echo "
\n"; echo " \n"; $myname=calculate_name($this->_dogInfo[$dog]); $callname="\"".rtrim($this->_dogInfo[$dog][callname])."\""; if($callname=="\"\"") $callname=""; echo " $myname "; echo " $callname\n"; $color=color($this->_dogInfo[$dog][color]); $gender=gender($this->_dogInfo[$dog][sex]); echo " $color $gender\n"; echo " \n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " Registration: \n"; $reg_num=$this->_dogInfo[$dog][reg_num]; echo " \n"; echo " $reg_num\n"; echo "
\n"; echo " Breeder: \n"; $breeder=$this->_dogInfo[$dog][breeder]; $origin=$this->_dogInfo[$dog][origin]; if ($origin!="") $origin="(".$origin.")"; echo " \n"; echo " $breeder $origin\n"; echo "
\n"; echo " Owner: \n"; echo " \n"; $owner=$this->_dogInfo[$dog][owner]; $residence=$this->_dogInfo[$dog][residence]; if ($residence!="") $residence="(".$residence.")"; echo " $owner $residence\n"; echo "
\n"; echo " Date of birth: \n"; echo " \n"; if ($this->_dogInfo[$dog][dob]=="0000-00-00") $dob=" "; else $dob=nicedate($this->_dogInfo[$dog][dob]); // $dob=date("F j, Y",strtotime($this->_dogInfo[$dog][dob])); echo " $dob\n"; echo "
\n"; echo " Health: \n"; $health=$this->_dogInfo[$dog][health]; echo " \n"; echo " $health\n"; echo "
\n"; echo "
"; $col=$depth-($bb-$c); $rw=$r/$rs; $mydog=$this->_ped[$col][$rw]; $myname=calculate_name($this->_dogInfo[$mydog]); if ($mydog>0) { $depth!=$default_depth ? $gens="?dog=$mydog&gen=$depth" : $gens="?dog=$mydog"; echo ""; } if (strlen($this->_dogInfo[$mydog][prefix])>0) echo "$myname"; else echo "$myname"; $reg_num=$this->_dogInfo[$mydog][reg_num]; $color=color($this->_dogInfo[$mydog][color]); $health=$this->_dogInfo[$mydog][health]; echo " $reg_num $color $health
"; echo ""; echo ""; echo "
"; echo " New search"; echo "
"; echo "
"; // FOOTER echo ""; echo ""; echo " "; echo " "; echo "
"; echo " Pedigree courtesy of Briardworld"; echo " "; echo " Generated by "; echo " phpPedigree 0.1"; echo "
"; echo ""; } function _getPedigree($dog,$depth=9) { $dogs=array($dog); for ($i=0; $i<$depth; $i++) { $result=$this->_getDogs($dogs); $num_rows=mysql_num_rows($result); // add this generation to dogInfo $dogs=array(); for($j=0; $j<$num_rows; $j++) { $row=mysql_fetch_array($result); $this_dog=$row[dog_id]; $this->_dogInfo[$this_dog]=$row; array_push($dogs,$row[sire]); array_push($dogs,$row[dam]); } } // now construct the pedigree array_push($this->_ped,array($dog)); for($i=0; $i<$depth; $i++) { $parents=array(); foreach ($this->_ped[$i] as $do) { $row=$this->_dogInfo[$do]; array_push($parents,$row[sire]); array_push($parents,$row[dam]); } array_push($this->_ped,$parents); } } function _getDogs($dogs) { $list=implode(", ",$dogs); $query= "select dogs.* from dogs where ". "dogs.dog_id in ($list)"; $result=mysql_query($query); $num_rows=mysql_num_rows($result); return($result); } } ?>