gillrowley
Programmer
Hello - need help figuring out what's wrong. I'm new to PHP. I'm trying to display info in one <div> section that is dependent on which hyperlink is clicked in another <div> section on the same page. The table and hyperlinks on the left side display properly, but I can't get anything to display on the right hand side. Help, please? Here's the code chunk.
<!-- left hand side - no problems except onclick doesnt work -->
<div class="content_half_left">
<?php include("includes/config.php"); ?>
<?php include("includes/opendb.php"); ?>
<?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=\"#\" onclick=\"displayDogs(".$dog_id.")\">".$dogName."</a></td>";
$display .= "<td>".$state."</td><td>".$rcontact."</td>";
$display .= "</tr>";
}
$display .= "</table>";
} else {
$display = "<p>Sorry, there are no dogs available at this time.</p>";
}
mysql_free_result($get_dogs_res);
echo $display;
?>
<?php include("includes/closedb.php"); ?>
</div>
<!-- right hand side - nothing displays here -->
<div class="content_half_right">
<p>Click on a dog's name to see the bio</p>
<?php function displayDogs($dog_id) {
$dog_info_query = "SELECT * FROM availabledogs WHERE dogID = ".$dog_id;
$dog_info_res = mysql_query($dog_info_query);
$get_dog_info = mysql_fetch_array($dog_info_res);
$dogName = $get_dog_info['dogName'];
$contact = $get_dog_info['rescueContact'];
$gender = $get_dog_info['gender'];
$result = "<h3>".$dogName."</h3>";
$result .= "<p>Rescue Contact: ".$contact."</p>";
$result .= "<p>Gender: ".$gender."</p>";
echo $result;
}
?>
</div>
<!-- left hand side - no problems except onclick doesnt work -->
<div class="content_half_left">
<?php include("includes/config.php"); ?>
<?php include("includes/opendb.php"); ?>
<?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=\"#\" onclick=\"displayDogs(".$dog_id.")\">".$dogName."</a></td>";
$display .= "<td>".$state."</td><td>".$rcontact."</td>";
$display .= "</tr>";
}
$display .= "</table>";
} else {
$display = "<p>Sorry, there are no dogs available at this time.</p>";
}
mysql_free_result($get_dogs_res);
echo $display;
?>
<?php include("includes/closedb.php"); ?>
</div>
<!-- right hand side - nothing displays here -->
<div class="content_half_right">
<p>Click on a dog's name to see the bio</p>
<?php function displayDogs($dog_id) {
$dog_info_query = "SELECT * FROM availabledogs WHERE dogID = ".$dog_id;
$dog_info_res = mysql_query($dog_info_query);
$get_dog_info = mysql_fetch_array($dog_info_res);
$dogName = $get_dog_info['dogName'];
$contact = $get_dog_info['rescueContact'];
$gender = $get_dog_info['gender'];
$result = "<h3>".$dogName."</h3>";
$result .= "<p>Rescue Contact: ".$contact."</p>";
$result .= "<p>Gender: ".$gender."</p>";
echo $result;
}
?>
</div>