"; } } ?>
Briard Pedigree Finder Search Results
0) { $p=new SearchResults($type,$value,$start,$order); $p->output(); } else { echo "Please enter something to search for:"; include_once("lib/form.inc"); } // ---------------------------------------------- class SearchResults { var $_list; var $_type; var $_value; var $_start; var $_order; var $_total; var $_ch_count; var $_health_count; var $PER_PAGE; function SearchResults($type,$value,$start,$order="") { $this->_list=array(); $this->_type=$type; $this->_value=$value; $this->_start=$start; $this->_order=$order; $this->_PER_PAGE=10; $this->_getList($type,$value,$start,$order); } function output() { global $HTTP_SERVER_VARS; $url="http://".$HTTP_SERVER_VARS[HTTP_HOST].$HTTP_SERVER_VARS['PHP_SELF']; $num_rows=mysql_num_rows($this->_list); if ($num_rows==0) { echo "No matching dogs found"; include("lib/form.inc"); } else { $stripped=stripslashes($this->_value); echo "

$this->_total dogs found "; if($this->_type!="off") echo "for $this->_type = \"$stripped\""; echo "
$this->_ch_count champions, $this->_health_count dogs with health certifications

"; echo "\n"; $this->_navbar(); $headings=array( "name"=>"Registered name", "callname"=>"Callname", "father"=>"Sire", "mother"=>"Dam", "regNum"=>"Registration number", "origin"=>"Country of origin", "breeder"=>"Breeder", "owner"=>"Owner", "dob"=>"Date of birth", "health"=>"Health certification"); echo ""; while($element=each($headings)) { echo ""; } reset($headings); echo ""; for ($i=0; $i<$num_rows; $i++) { $dog=mysql_fetch_array($this->_list); echo ""; $cell_color=""; if($i%2==0) $cell_color="bgcolor=\"#F0F0F0\""; else $cell_color="bgcolor=\"#C9C9C9\""; while ($element=each($headings)) { $key=$element[key]; if($key=="name") { $color=color($dog[color]); $sex=gender($dog[sex]); $item="". trim(stripslashes($dog[calculated_name]))."
". "$color $sex"; } else $item=$dog[$key]; if($key=="sire" || $key=="dam" || $key=="father" || $key=="mother") { $item=trim(stripslashes($dog[$key])); } if($item=="") $item=" "; if($key=="dob" && $item=="0000-00-00") $item=" "; echo ""; } reset($headings); echo ""; } $this->_navbar(); echo "
"; $urlified=urlencode($this->_value); echo "_type&value=$urlified"; if ($this->_start!=0) echo "&start=$this->_start"; if ($element[key]!="name") echo "&order=$element[key]"; echo "\">$element[value]
$item
"; } } function _getList($type,$value,$start,$order) { $tables = 'FROM _animals INNER JOIN _litters ON (_animals.animalLitterId = litterId) INNER JOIN _animals AS father ON (fatherId = father.animalId) INNER JOIN _animals AS mother ON (motherId = mother.animalId) WHERE '; $queries=array( 'total' => array('select' => 'SELECT COUNT(*) ','where' => ' '), 'ch' => array('select' => 'SELECT COUNT(*) ','where' => '_animals.prefix LIKE "%ch%" AND '), 'health' => array('select' => 'SELECT COUNT(*) ','where' => '_animals.health != "" AND '), 'list' => array('select' => 'SELECT _animals.*, _animals.name AS name, concat(_animals.prefix," ",_animals.name," ",_animals.suffix) AS calculated_name, concat(father.prefix," ",father.name," ",father.suffix) AS father, concat(mother.prefix," ",mother.name," ",mother.suffix) AS mother, father.name AS fathername, mother.name AS mothername ') ); while ($element=each($queries)) { $query_type=$element[key]; $query=$element[value]; $query = $query['select'].$tables.$query['where']; switch($type) { case "name": case "callname": case "origin": case "breeder": case "owner": case "regNum"; case "health": $words=preg_split ("/[\s,]+/",$value); $query.="_animals.$type REGEXP \""; foreach ($words as $word) { $query .= "[[:<:]]$word.*"; } $query .= '"'; break; case "father": case "mother": $words=preg_split ("/[\s,]+/",$value); $query.="$type.name REGEXP \""; foreach ($words as $word) { $query .= "[[:<:]]$word.*"; } $query .= '"'; break; case "dob": $query.="_animals.dob=\"$value\""; break; case "off": $query.="((father.id=$this->_value) OR (mother.id=$this->_value))"; break; } switch($query_type) { case "total": $result=mysql_query($query); $count=mysql_fetch_array($result); $this->_total=$count[0]; break; case "ch": $result=mysql_query($query); $count=mysql_fetch_array($result); $this->_ch_count=$count[0]; break; case "health": $result=mysql_query($query); $count=mysql_fetch_array($result); $this->_health_count=$count[0]; break; case "list": if ($order=="") $set_order=" order by name "; else if ($order=="father") $set_order=" order by fathername, dob "; else if ($order=="mother") $set_order=" order by mothername, dob "; else $set_order=" order by $order, name "; $query.=$set_order; $query.="limit $start, $this->_PER_PAGE"; $this->_list=mysql_query($query); break; } } } function _navbar() { $urlified=urlencode($this->_value); $url="_type&value=$urlified"; echo "
"; echo ""; echo "\n"; echo "\n"; echo "
"; if ($this->_start!=0) { echo "$url"; if ($this->_order!="") echo "&order=$this->_order"; echo "\"><< first "; $prev=$this->_start-$this->_PER_PAGE; echo "$url"; if ($prev!=0) echo "&start=$prev"; if ($this->_order!="") echo "&order=$this->_order"; echo "\">< previous"; } echo " \n"; if($this->_start+$this->_PER_PAGE<$this->_total) { $next=$this->_start+$this->_PER_PAGE; echo "$url&start=$next"; if ($this->_order!="") echo "&order=$this->_order"; echo "\">next > "; $last=floor($this->_total/$this->_PER_PAGE)*$this->_PER_PAGE; echo "$url&start=$last"; if ($this->_order!="") echo "&order=$this->_order"; echo "\">last >>"; } echo " 
New search
Sponsored by Briardworld Generated by phpPedigree 0.1