HOST,'user'=>DBUSER,'password'=>DBPASS,'database'=>DBNAME)); $siteDataObj = new SiteData($dbObj); $stateDataArr = getStateArr($dbObj); $breedsdDataArr = getBreedsArr($dbObj); $breedsLinkArr = getBreedsLinkArr($dbObj); if(!isset($_GET['page']))$_GET['page'] = 1; $cityList = array(); // determine page request type if(trim($_SERVER['QUERY_STRING'])==""){ // show state list of breeders with count $breedersArr = array(); $html = "

Welcome to ".$siteDataObj -> siteName." gamebird farms and poultry breeder listings.
You can find game bird hatcheries by clicking a state or game bird breed.

\n"; $html .= "

Game Bird Hatcheries by state

"; $query = "SELECT COUNT(breeders.id) as breederCount, state.stateName, countries.country FROM state LEFT JOIN breeders ON (state.id = breeders.state AND breeders.active = 1), countries WHERE state.country = countries.id GROUP BY state.id ORDER BY state.stateName"; $dbObj->performQuery($query); while($row = $dbObj->fetchRow()){ $breedersArr[$row['country']][] = $row; } foreach($breedersArr as $key => $value){ $itemArr = array(); if(is_array($value) && count($value)>0){ foreach($value as $stateBreederData){ $itemArr[] = "{$stateBreederData['stateName']}". (($stateBreederData['breederCount']>0)?" (".$stateBreederData['breederCount'].")":""); } } $html.= tableResults($itemArr,3,100,$key,"",'class="tableList"'); } $html .= "

Gamebird breeders by breed

"; // clear breeders array for next data set $breedersArr = array(); $itemArr = array(); $query = "SELECT breeds FROM breeders WHERE active = 1"; $dbObj->performQuery($query); while($row = $dbObj->fetchRow()){ if(trim($row['breeds'])!=""){ $tBreedArr = explode(",",$row['breeds']); foreach($tBreedArr as $value){ $breedersArr[$value]++; } } } foreach($breedsLinkArr as $key => $value){ if(trim($value)!="" && $key != 0){ $itemArr[] = "{$breedsdDataArr[$key]}". ((array_key_exists($key,$breedersArr))?" (".$breedersArr[$key].")":"")."
"; } } $html.= tableResults($itemArr,2,100,""); $pageTitle = "Game Bird Hatchery Listings"; $metaDescription = "Find game bird hatcheries by State or by breed."; $metaKeywords = "Gamebird farms, poultry breeders, birds for sale, ducks, chickens, pheasant chicks, quail eggs, peafowl, pigeons "; // record hit $dbObj->performQuery("INSERT INTO traffic SET mark = NOW(), referringIP = '{$_SERVER['REMOTE_ADDR']}', type = 'incoming', pageType='breeder'"); } else if(isset($_GET['breederName']) && isset($_GET['stateID'])){ // show breeder data $query = "SELECT breeders.id, breeders.name, breeders.linkName, breeders.services, breeders.address, breeders.zip, cities.city, breeders.phone, breeders.secPhone, breeders.contact, breeders.writeup, breeders.businessYrs, breeders.breeds, breeders.dateModified, breeders.logo, breeders.imgExt, breeders.email, breeders.website, state.stateName, count(classifieds.id) as classifiedsCount FROM breeders LEFT JOIN classifieds ON classifieds.ownerID = breeders.id AND classifieds.expires >= NOW(), state, cities WHERE breeders.state = state.id AND breeders.linkName LIKE '".linkFormat::stripDashes($_GET['breederName'])."' AND breeders.city = cities.id AND breeders.active = 1 AND state.stateName LIKE '".LinkFormat::stripDashes($_GET['stateID'])."' GROUP BY breeders.id"; $dbObj->performQuery($query); if($row = $dbObj->fetchRow()){ $html = ""; $services = ""; $row['city'] = capFirst($row['city']); if(trim($row['logo']!="" && trim($row['imgExt']!=""))){ if($row['imgExt']==".png"){ } else { $html.= "siteURL."/logoImages/".$row['id'].$row['imgExt']."\" alt=\"".$row['name']."\" class=\"breederLogo\"/>
"; } } $breederID = $row['id']; if(trim($row['writeup'])!=""){ $html .= "
About ".$row['name']."
"; $html .= "
".preg_replace("~ ~"," ",$row['writeup'])."
"; } $thisBreedsArr = getBreedNames($row['breeds'],$breedsdDataArr); $html .= "
Game Birds Raised
"; $html .= "
".implode(", ",$thisBreedsArr)."
"; if(trim($row['services'])!=""){ $services = str_replace(",",", ",$row['services']); $html .= "
Additional Services
"; $html .= "
$services
"; } $html .= "
Contact Info
"; $html .= "
".$row['contact']."
"; if(trim($row['address'])!="")$html .= $row['address']."
"; if(trim($row['city'])!="")$html .= $row['city'].", "; $html .= $row['stateName']; if(trim($row['zip'])!="")$html .= " ".$row['zip']; $html .="
"; if($row['businessYrs']>0){ $html .= "
Breeding game birds for over {$row['businessYrs']} years.
"; } if(trim($row['phone'])!="") $html .= "
".$row['phone']."
"; if(trim($row['secPhone'])!="") $html .= "
".$row['secPhone']."
"; if(trim($row['email'])!="") $html .= "siteURL}/contactHatchery{$breederID}.html\" class=\"email\">Send Email to {$row['name']}"; if(trim($row['website'])!="") $html .= "Click here to visit {$row['name']} website
"; $html .= "
"; if($row['classifiedsCount']>0){ $html .= "
Birds for sale
"; $query = "SELECT title,id FROM classifieds WHERE classifieds.ownerID = $breederID AND expires >= NOW() ORDER BY dateAdded DESC"; $dbObj->performQuery($query); while($cRow = $dbObj->fetchRow()){ $html.="siteURL."/classifieds/".$cRow['id'].".html\" class=\"breederSMLink\">".$cRow['title'] .""; } } // get testimonials $query = "SELECT name, dateCreated, rating, comment FROM reviews WHERE ownerID = ".$row['id']." AND active = 1 ORDER BY dateCreated DESC"; $dbObj->performQuery($query); $reviewArr =array(); while($rRow = $dbObj->fetchRow()){ $reviewArr[] = "
Submitted by: ".$rRow['name']." on ".formatDate($rRow['dateCreated'])."
".nl2br($rRow['comment']); } $html .= "
Testimonials (".count($reviewArr).")
"; $html .= "
"; if(count($reviewArr)>0){ $html .= implode("
",$reviewArr); } else { $html .= "No testimonials for this hatchery"; } $html .= "

siteURL."/testimonials.html?breederID=".$row['id']."\">>> Submit your testimonial

"; $html .= "

"; $pageTitle = "{$row['name']} - {$row['city']}, {$row['stateName']} Game Bird Breeders"; $metaDescription = showFirst($row['writeup'],255); $metaKeywords = showFirst($row['name'],255).", ".$row['stateName']." game bird breeder, ".implode(", ",$thisBreedsArr).", chicks for sale, hatching eggs, mature birds, hatcheries, poultry, waterfowl, supplies".((trim($services)!="")?" ,$services":""); // record hit $dbObj->performQuery("INSERT INTO traffic SET mark = NOW(), referringIP = '{$_SERVER['REMOTE_ADDR']}', breederID= {$row['id']}, type = 'incoming', pageType='breeder'"); } else { $html = showImproperRequest(); $pageTitle = "Error"; } } else if(isset($_GET['breeds'])){ // show breeders by breeds. $html = ""; $query = "SELECT breeds,description FROM breeds WHERE breeds LIKE '".LinkFormat::stripDashes($_GET['breeds'],SQLREADY)."%'"; $dbObj->performQuery($query); if($row = $dbObj->fetchRow()){ $breed = $row['breeds']; } else { showImproperRequest(); exit(); } $query = "SELECT breeders.name,breeders.linkName,breeders.services,cities.city, breeders.breeds, breeders.dateModified, state.stateName, count(classifieds.id) as classifiedsCount, breeds.id as breedIdent, COUNT(reviews.id) as reviewCount FROM (breeders LEFT JOIN reviews ON reviews.ownerID = breeders.id) LEFT JOIN classifieds ON classifieds.ownerID = breeders.id AND classifieds.expires >= NOW(), state, breeds,cities WHERE breeders.state = state.id AND breeders.active = 1 AND breeds.breeds LIKE '".LinkFormat::stripDashes($_GET['breeds'],SQLREADY)."' AND breeders.breeds REGEXP CONCAT('(,|^)',breeds.id,'(,|$)') AND cities.id = breeders.city GROUP BY breeders.id ORDER BY IF(breeders.expires >=NOW(),0,1), reviewCount DESC, breeders.businessYrs DESC, classifiedsCount DESC"; $pg=&new Pager($dbObj,$query,50); $resArr = $pg->displayRecords($_GET['page'],"breeders"); if(count($resArr['results'])>0){ $html = "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; $a = 0; foreach($resArr['results'] as $row){ $thisBreedsArr = getBreedNames($row['breeds'],$breedsdDataArr); $html .= formatListing($row, $a, $siteDataObj, $thisBreedsArr); $stateName = $row['stateName']; $a++; } if($a>5) $html .= "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; } else { $html .= "

About the ".$breed."
".$row['description']."


"; $html .= "

Sorry, we do not have any listings for this game bird breed

"; $html .= "

siteURL.$_SERVER['PHP_SELF']."\">Click here to do another search.

"; } $pageTitle = "$breed game bird hatcheries"; $metaDescription = "Find $breed breeders who raise $breed chicks and offer $breed hatching eggs for sale."; $metaKeywords = "$breed breeders, $breed chicks for sale, hatching eggs, hatchery, mature birds, birds for sale, pairs, rare breeds"; // record hit $dbObj->performQuery("INSERT INTO traffic SET mark = NOW(), referringIP = '{$_SERVER['REMOTE_ADDR']}', breedID = (SELECT id FROM breeds WHERE breeds LIKE '".Linkformat::stripDashes($_GET['breeds'])."'), type = 'incoming', pageType='breeder'"); } else if(isset($_GET['stateID']) && isset($_GET['city'])){ // Breeders by City // show classifieds by city // check that state and city exists in database $query = "SELECT state.*, cities.id as cityID, cities.city FROM state, cities WHERE state.stateName LIKE '".Linkformat::stripDashes($_GET['stateID'])."' AND cities.city LIKE '".Linkformat::stripDashes($_GET['city'])."%' AND cities.stateID = state.id"; $dbObj->performQuery($query); if($dbObj->getNumRows()==0){ $html = showImproperRequest(); } else { $tempStateData = $dbObj->fetchRow(); $thisState = $tempStateData['stateName']; $thisCity = capFirst($tempStateData['city']); $tempCityArr = getCityList($dbObj, $tempStateData['id']); $linkState = Linkformat::addDashes($_GET['stateID'],lcase); foreach($tempCityArr as $key => $value){ $cityList[] = "siteURL/hatcheries-$linkState/".Linkformat::addDashes($key,lcase)."\" class=\"breederSMLink\">".capFirst($key)." ($value)"; } } $query = "SELECT breeders.name,breeders.linkName,breeders.services,cities.city, breeders.breeds, breeders.dateModified, state.stateName,state.abbv, count(classifieds.id) as classifiedsCount, COUNT(reviews.id) as reviewCount FROM (breeders LEFT JOIN reviews ON reviews.ownerID = breeders.id) LEFT JOIN classifieds ON classifieds.ownerID = breeders.id AND classifieds.expires >= NOW() , state, cities WHERE breeders.state = {$tempStateData['id']} AND breeders.city = {$tempStateData['cityID']} AND breeders.state = state.id AND breeders.active = 1 AND cities.id = breeders.city GROUP BY breeders.id ORDER BY IF(breeders.expires >=NOW(),0,1), reviewCount DESC, breeders.businessYrs DESC, classifiedsCount DESC"; $pg=&new Pager($dbObj,$query,50); $resArr = $pg->displayRecords($_GET['page'],"breeders"); $stateClassifiedLink = "siteURL."/classifieds/{$_GET['stateID']}/{$_GET['city']}.html\">View current classified ads by bird hatcheries in $thisCity, $thisState."; if(count($resArr['results'])>0){ $html = "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; $a = 0; foreach($resArr['results'] as $row){ $thisBreedsArr = getBreedNames($row['breeds'],$breedsdDataArr); $html .= formatListing($row, $a, $siteDataObj, $thisBreedsArr); $stateName = "{$row['abbv']} – {$row['stateName']}"; $a++; } if($a>5) $html .= "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; } else { $html .= "

Sorry, we don't have any listings for bird hatcheries in $thisCity, $thisState.

"; $html .= "

siteURL.$_SERVER['PHP_SELF']."\">Click here to do another search.

"; } $pageTitle = "$thisCity, $thisState Bird Breeders"; $metaDescription = "Find game bird breeders in $thisCity, $thisState with chicks for sale, hatching eggs, mature birds raised and hatched in $thisState hatcheries."; $metaKeywords = "$thisCity - $thisState game bird breeders, chicks for sale, $thisCity - $thisState hatcheries, poultry, waterfowl, hatching eggs, game birds, adult birds, day old"; // record hit $dbObj->performQuery("INSERT INTO traffic SET mark = NOW(), referringIP = '{$_SERVER['REMOTE_ADDR']}', stateID = {$tempStateData['id']}, type = 'incoming', pageType='breeder'"); } else if(isset($_GET['stateID'])){ // Breeders by State // assumes only state has been set $dbObj->performQuery("SELECT * FROM state WHERE stateName LIKE '".Linkformat::stripDashes($_GET['stateID'])."'"); if($dbObj->getNumRows()==0){ $html = showImproperRequest(); } else { $tempStateData = $dbObj->fetchRow(); $tempCityArr = getCityList($dbObj, $tempStateData['id']); $linkState = Linkformat::addDashes($_GET['stateID'],lcase); foreach($tempCityArr as $key => $value){ $cityList[] = "siteURL/hatcheries-$linkState/".Linkformat::addDashes($key,lcase)."\" class=\"breederSMLink\">".capFirst($key)." ($value)"; } } $stateID = LinkFormat::stripDashes($_GET['stateID']); $query = "SELECT breeders.name,breeders.linkName,breeders.services,cities.city, breeders.breeds, breeders.dateModified, state.stateName,state.abbv, count(classifieds.id) as classifiedsCount, COUNT(reviews.id) as reviewCount FROM (breeders LEFT JOIN reviews ON reviews.ownerID = breeders.id) LEFT JOIN classifieds ON classifieds.ownerID = breeders.id AND classifieds.expires >= NOW() , state, cities WHERE breeders.state = state.id AND breeders.active = 1 AND state.stateName LIKE '$stateID' and cities.id = breeders.city GROUP BY breeders.id ORDER BY IF(breeders.expires >=NOW(),0,1), reviewCount DESC, breeders.businessYrs DESC, classifiedsCount DESC"; $pg=&new Pager($dbObj,$query,50); $resArr = $pg->displayRecords($_GET['page'],"breeders"); $stateClassifiedLink = "siteURL."/classifieds/{$_GET['stateID']}.html\">View current classified ads by bird hatcheries in $stateID."; if(count($resArr['results'])>0){ $html = "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; $a = 0; foreach($resArr['results'] as $row){ $thisBreedsArr = getBreedNames($row['breeds'],$breedsdDataArr); $html .= formatListing($row, $a, $siteDataObj, $thisBreedsArr); $stateName = "{$row['abbv']} - {$row['stateName']}"; $a++; } if($a>5) $html .= "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; } else { $query = "SELECT stateName, abbv FROM state WHERE stateName LIKE '$stateID'"; $dbObj->performQuery($query); if($row = $dbObj->fetchRow()){ $stateName = "{$row['abbv']} – {$row['stateName']}"; $html .= "

Sorry, we don't have any listings for Bird Breeders in this state.

"; $html .= "

siteURL.$_SERVER['PHP_SELF']."\">Click here to do another search.

"; } else { showImproperRequest(); exit(); } } $pageTitle = "{$row['stateName']} Game Bird Hatcheries"; $metaDescription = "Find game bird breeders in {$row['stateName']} with chicks for sale, hatching eggs, and other poultry and waterfowl hatcheries in {$row['stateName']}."; $metaKeywords = "{$row['stateName']} game birds, {$row['stateName']} hatcheries, {$row['stateName']} hatching eggs, chicks for sale, mature birds, day old chicks, poultry, waterfowl hatchery, peafowl, chickens, pheasants, quail"; // record hit $dbObj->performQuery("INSERT INTO traffic SET mark = NOW(), referringIP = '{$_SERVER['REMOTE_ADDR']}', stateID = (SELECT id FROM state WHERE stateName LIKE '$stateID'), type = 'incoming', pageType='breeder'"); } else if(isset($_GET['group'])){ // breeders by group $grouptoquery = ucfirst(LinkFormat::stripDashes($_GET['group'])); $html = ""; $query = "SELECT breeders.name,breeders.linkName,breeders.services,cities.city, breeders.breeds, breeders.dateModified, state.stateName, count(classifieds.id) as classifiedsCount, breeds.id as breedIdent, COUNT(reviews.id) as reviewCount FROM (breeders LEFT JOIN reviews ON reviews.ownerID = breeders.id) LEFT JOIN classifieds ON classifieds.ownerID = breeders.id AND classifieds.expires >= NOW(), state, breeds,cities WHERE breeders.state = state.id AND breeders.active = 1 AND breeds.parentgroup LIKE '$grouptoquery' AND breeders.breeds REGEXP CONCAT('(,|^)',breeds.id,'(,|$)') AND cities.id = breeders.city GROUP BY breeders.id ORDER BY IF(breeders.expires >=NOW(),0,1), reviewCount DESC, breeders.businessYrs DESC, classifiedsCount DESC"; $pg=&new Pager($dbObj,$query,40); $resArr = $pg->displayRecords($_GET['page'],$_GET['group']); if(count($resArr['results'])>0){ $html = "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; $a = 0; foreach($resArr['results'] as $row){ $thisBreedsArr = getBreedNames($row['breeds'],$breedsdDataArr); $html .= formatListing($row, $a, $siteDataObj, $thisBreedsArr); $stateName = $row['stateName']; $a++; } if($a>5) $html .= "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; } else { $html .= "

Sorry, we do not have any listings for $grouptoquery

"; $html .= "

siteURL.$_SERVER['PHP_SELF']."\">Click here to do another search.

"; } // record hit //$dbObj->performQuery("INSERT INTO traffic SET mark = NOW(), referringIP = '{$_SERVER['REMOTE_ADDR']}', breedID = (SELECT id FROM breeds WHERE breeds LIKE '".Linkformat::stripDashes($_GET['breeds'])."'), type = 'incoming', pageType='breeder'"); $pageTitle = "$grouptoquery Game Bird Hatcheries"; $metaDescription = "Game bird hatcheries offering $grouptoquery for sale as well as chicks and $grouptoquery hatching eggs."; $metaKeywords = "game birds, hatcheries, hatching eggs, chicks for sale, mature birds, day old chicks, poultry, waterfowl hatchery, peafowl, chickens, pheasants, quail"; } else if(isset($_GET['allBreeders'])){ // All breeders by alpha $resultsPerPage = 50; $query = "SELECT breeders.name,breeders.linkName,cities.city,breeders.breeds,breeders.dateModified, state.stateName, count(classifieds.id) as classifiedsCount FROM state, breeders LEFT JOIN classifieds ON (breeders.id = classifieds.ownerID AND classifieds.expires >= NOW()),cities WHERE breeders.active = 1 AND breeders.state = state.id AND breeders.city = cities.id GROUP BY breeders.id ORDER BY IF(breeders.expires >=NOW(),0,1), breeders.name"; $pg=&new Pager($dbObj,$query,$resultsPerPage); $resArr = $pg->displayRecords($_GET['page'],"allBreeders"); $a = 0; if(count($resArr['results'])>0){ $html = "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; foreach($resArr['results'] as $row){ $thisBreedsArr = getBreedNames($row['breeds'],$breedsdDataArr); $html .= formatListing($row, $a, $siteDataObj, $thisBreedsArr); $stateName = $row['stateName']; $a++; } if($a>5) $html .= "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; } $pageTitle = "All Game Bird Hatcheries in USA and Canada"; $metaDescription = "Find gamebird breeders in USA and Canada with chicks for sale, hatching eggs, and game bird hatchery supplies."; $metaKeywords = "game birds, hatcheries, hatching eggs, chicks for sale, mature birds, day old chicks, poultry, waterfowl hatchery, peafowl, chickens, pheasants, quail"; $metaSEO = ""; } else { showImproperRequest(); exit(); } ?> <?= $pageTitle ?> - <?= $siteDataObj -> siteName?> metaDescription) ?>"/> metaKeywords) ?>"/> 0){ ?>
Gamebird hatcheries
by city in

$stateClassifiedLink"; ?>
Is your bird hatchery listed? Add your hatchery today!
siteURL."/hatcheries-".LinkFormat::addDashes($row['stateName'],lcase)."/".LinkFormat::addDashes($row['city'],lcase)."/".LinkFormat::addDashes($row['linkName'],lcase).".html\" class=\"breederLink\">".$row['name'].""; $html .= " ".capFirst($row['city'])." - ".$row['stateName']."
"; if($row['classifiedsCount']!="0") $html .= "We currently have an active classified
"; if(count($thisBreedsArr)>0) $html .= "Breeds Raised: ".implode(", ",$thisBreedsArr).""; $html .= ""; return $html; } function getBreedNames($breeds,&$breedsdDataArr){ $thisBreedsArr = array(); $dbBreeds = explode(",",$breeds); if(count($dbBreeds)>0){ foreach($dbBreeds as $value){ if($value!=0){ $thisBreedsArr[] = $breedsdDataArr[$value]; } } } return $thisBreedsArr; } function getCityList(&$dbObj, $stateID){ $returnArr = array(); $dbObj->performQuery("SELECT ci.*, count(br.id) as breederCount FROM cities ci, breeders br WHERE ci.stateID = $stateID AND br.city = ci.id /*AND br.expires >= NOW()*/ GROUP BY ci.id ORDER BY ci.city"); while($row = $dbObj->fetchRow()){ $returnArr[capFirst($row['city'])] = $row['breederCount']; } return $returnArr; } ?>