Greetings all,
I have a webpage that provides the listings of churches taken from a table within our database. The structure of the database includes:
CH_ID, CH_name, CH_addr, CH_city, CH_state, CH_zip, CH_phone, CH_addinfo
By default, when opening the page, it lists the entire contents of the table by name of the church.
I tried to hardcode links by state, so that if someone clicked on the link (*.php?state=CA), it would then list the churches in that state (using CH_state as the check).
The first part works, but clicking on the link for the state returns a blank table. Problem has to be in the call made.
Here is the test page:
http://www.lithuaniangenealogy.org/test/test8.php
Here is the code:
<?php
include("../../includes/lithparishes.inc");
$dbh=@mysql_connect ("$dbhost", "$dbuser", "$dbpass") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("$dbname");
$qryState = "%";
echo "<a href=\"test8.php?state=CA\">California</a> | <a href=\"test8.php?state=IL\">Illinois</a><br> ";
$letter = $_GET["state"];
if (isset($state))
{
$qryChurch = "SELECT * FROM lithparishes WHERE CH_name LIKE '$state%'";
} else {
$qryChurch = "SELECT * FROM lithparishes ORDER BY CH_name";
}
$result = mysql_query($qryChurch);
echo "<TABLE BORDER=1 cellpadding=5>";
echo "<tr bgcolor=\"#9999CC\">";
echo "<td width=30%><strong>Church Name/Address</strong></td>";
echo "<td width=25%><strong>Additional Information</strong></td>\n";
echo "</tr>";
while ($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><strong>{$row['CH_name']}</strong><br> Address:<em>{$row['CH_addr']}</em><br> City/State: {$row['CH_city']},{$row['CH_state']},{$row['CH_zip']}<br> Phone:{$row['CH_phone']}</td>";
echo "<td>{$row['CH_addinfo']}</td>";
echo "</tr>";
}
echo "</TABLE>";
$today = date("l dS of F Y h:i a");
print "<CENTER>Today is $today (server time)</CENTER>";
?>
Thanks for the help!