Greetings all,
I have the following PHP code on a webpage:
$qryState = "%";
echo "<a href=\"test8.php?state=CA\">California</a> | <a href=\"test8.php?state=CT\">Connecticut</a> | <a href=\"test8.php?state=IL\">Illinois</a><br> ";
$state = $_GET["state"];
if (isset($state))
{
$qryChurch = "SELECT * FROM lithparishes WHERE CH_state LIKE '$state%'";
} else {
$qryChurch = "SELECT * FROM lithparishes ORDER BY CH_name";
}
When you initially go to this page, it will run the else part of the statement and list all the churches by alphabetical order.
Once the page opens, if you want to see all the churches from a particular state, you click on the HREF link where it will query the table and check the field CH_state for the matching state variable.
For the most part this works. However, I found out that if there is a blank space before the state initials in CH_state, it will not list the church. But, if I delete the single space before the state variable in CH_state, it will list the church.
So, question is, what do I need to change in the above code to get it to search the entire string from CH_state so that IF there is a space in there, it will still list the church.
Thanks!