<?php
$get_dogs_sql = "SELECT *, stateName FROM availabledogs ";
$get_dogs_sql .= "INNER JOIN states on state = stateCode ";
$get_dogs_sql .= "ORDER BY state, dogName";
$get_dogs_res = mysql_query($get_dogs_sql);
if (mysql_num_rows($get_dogs_res) > 0) {
$display = "<table cellpadding=1 cellspacing=0 border=0 width=\"100%\">";
$display .= "<tr><th>Dog</th><th>State</th><th>Rescue Contact</th></tr>";
while ($get_info = mysql_fetch_array($get_dogs_res)) {
$dog_id = $get_info['dogID'];
global $dog_id;
$dogName = $get_info['dogName'];
$state = $get_info['stateName'];
$rcontact = $get_info['rescueContact'];
$display .= "<tr>";
$display .= "<td><a href=\"".$_SERVER['PHP_SELF']."?dog_id=".$dog_id."\">".$dogName."</a></td>";
$display .= "<td>".$state."</td><td>".$rcontact."</td>";
$display .= "</tr>";
}
$display .= "</table>";
$display .= "<br><br><br>";
$display .= "<a href=\"adoption_application.php\">Click here to start the adoption process.</a>";
} else {
$display = "<p>Sorry, there are no dogs available at this time.</p>";
}
mysql_free_result($get_dogs_res);
echo $display;
echo "</div>";
echo "<div class=\"content_half_right\">";
if (isset($_GET["dog_id"])) {
$dog_info_query = "SELECT * FROM availabledogs WHERE dogID = ".$_GET["dog_id"];
$dog_info_res = mysql_query($dog_info_query);
$get_dog_info = mysql_fetch_array($dog_info_res);
$dogName = $get_dog_info['dogName'];
$dogColor = $get_dog_info['dogColor'];
$dogWeight = $get_dog_info['dogWeight'];
$dogAge = $get_dog_info['dogAge'];
if ($get_dog_info['housebroken']) {
$housebroken = "Yes";
} else {
$housebroken = "No";
}
if ($get_dog_info['leashTrained']) {
$leashTrained = "Yes";
} else {
$leashTrained = "No";
}
if ($get_dog_info['crateTrained']) {
$crateTrained = "Yes";
} else {
$crateTrained = "No";
}
$imagePath = $get_dog_info['imagePath'];
$contact = $get_dog_info['rescueContact'];
$contactEmail = $get_dog_info['contactEmail'];
$contactPhone = $get_dog_info['contactPhone'];
$gender = $get_dog_info['gender'];
$narrative = $get_dog_info['narrative'];
$result = "<h2>".$dogName."</h2>";
$result .= "<table cellpadding=0 cellspacing=0 border=0 width=100%>";
$result .= "<tr><td>Gender:</td><td>".$gender."</td>";
$result .= "<td rowspan=8 valign=\"top\">";
$result .= "<a href=\"".$imagePath."\" target=\"_blank\"><img src=\"".$imagePath."\" border=0 width=\"75\" height=\"56\"></a></td>";
$result .= "</tr>";
$result .= "<tr><td>Color</td><td>".$dogColor."</td></tr>";
$result .= "<tr><td>Weight</td><td>".$dogWeight."</td></tr>";
$result .= "<tr><td>Age</td><td>".$dogAge."</td></tr>";
$result .= "<tr><td>Housebroken?</td><td>".$housebroken."</td></tr>";
$result .= "<tr><td>Leash Trained?</td><td>".$leashTrained."</td></tr>";
$result .= "<tr><td>Crate Trained</td><td>".$crateTrained."</td></tr>";
$result .= "<tr><td>Rescue Contact</td><td>".$contact."</td></tr>";
$result .= "<tr><td>Email</td><td colspan=2><a href=\"mailto:".$contactEmail."\">".$contactEmail."</a></td></tr>";
$result .= "<tr><td>Phone Number</td><td colspan=2>".$contactPhone."</td></tr>";
$result .= "<tr><td colspan=3>" "</td></tr>";
$result .= "<tr><td colspan=3>".$narrative."</td></tr>";
$result .= "</table>";
echo $result;
}
?>