HOST,'user'=>DBUSER,'password'=>DBPASS,'database'=>DBNAME)); $siteDataObj = new SiteData($dbObj); $stateDataArr = getStateArr($dbObj); $breedsdDataArr = getBreedsArr($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." kennel and breeder listing.
You can find dog breeders by clicking a State or Dog Breed.

\n"; $html .= "

Dog breeders 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 .= "

Dog 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($breedsdDataArr as $key => $value){ if(trim($value)!="" && $key != 0){ $itemArr[] = "$value". ((array_key_exists($key,$breedersArr))?" (".$breedersArr[$key].")":"")."
"; } } $html.= tableResults($itemArr,2,100,""); $pageTitle = "Dog Breeder Kennel Listings"; $metaDescription = "Find dog breeders by State or by dog breed. Dog kennel listings and puppy for sale classified ads include started and finished dogs for sale."; $metaKeywords = "dogs, dogs, dog breeders, kennel, puppy for sale, started, finished, male, female, puppies, USA and Canada"; // 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 .= "
Breeds 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 quality dogs 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}/contactBreeder{$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 .= "
Puppies 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 breeder"; } $html .= "

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

"; $html .= "

"; $pageTitle = "{$row['name']} - {$row['city']}, {$row['stateName']} Dog Breeders"; $metaDescription = showFirst($row['writeup'],255); $metaKeywords = showFirst($row['name'],255).", ".$row['stateName']." dog breeder, ".implode(", ",$thisBreedsArr).", puppy for sale, litter, started, finished, stud, breed, puppies, dogs".((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,breeders.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 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,'(,|$)') 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 dog breed

"; $html .= "

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

"; } $pageTitle = "$breed Breeders"; $metaDescription = "Find $breed dog breeders who raise $breed puppies and offer started dogs, finished dogs and stud services for sale."; $metaKeywords = "$breed breeders, $breed puppy for sale, Female, Male, Puppies, Breeder, Kennel, Started, Finished, stud, pup"; // 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/kennels-$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 dog breeders 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 Dog Breeders in $thisCity, $thisState.

"; $html .= "

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

"; } $pageTitle = "$thisCity, $thisState Dog Breeders"; $metaDescription = "Find dog breeders in $thisCity, $thisState with puppies for sale as well as started and finished dogs raised and trained in $thisState."; $metaKeywords = "$thisCity - $thisState dog breeders, puppy for sale, $thisCity - $thisState dog kennels, breeder, kennel, puppies, female, male, pup"; // 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/kennels-$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 dog breeders 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 Dog Breeders in this state.

"; $html .= "

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

"; } else { showImproperRequest(); exit(); } } $pageTitle = "$stateName Dog Breeders"; $metaDescription = "Find dog breeders in $stateName with puppies for sale as well as started and finished dogs raised and trained in $stateName."; $metaKeywords = "$stateName dog breeders, puppy for sale, $stateName dog kennels, breeder, kennel, puppies, female, male, pup"; // 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['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 Dog Breeders in USA and Canada"; $metaDescription = "Find dog breeders in USA and Canada with puppies for sale as well as started dogs, finished dogs and training for dogs."; $metaKeywords = "dog, dog breeder, USA dog breeders, Canada puppy for sale, kennel, started, finished dogs, training, pup"; $metaSEO = ""; } else { showImproperRequest(); exit(); } ?> <?= $pageTitle ?> - <?= $siteDataObj -> siteName?> metaDescription) ?>"/> metaKeywords) ?>"/> 0){ ?>
Kennels by city in

$stateClassifiedLink"; ?>
Is your dog kennel listed? Add your kennel today!
siteURL."/kennels-".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; } ?>