PHP question; I know this is alot, but I'm desperate.
This script actually calls the whole table rather then meeting the search parameters. Can someone help with altering the php script to actually do what I want it to, find matches for searchtype and searchterm?
Thanks - Desperate
This is from form.htm
<form action="results.php" method="post">
<p>Search by:
<select name="searchtype">
<option value="name">Organization Name
<option value="denomination">Denomination
<option value="city">City
</select>
Keyword:
<input type="text" name="searchterm">
<input type="submit" value="Search">
</p>
</form>
This is from results.php
//feild names if you need them;
//name, pastor, denomination, address, city, state, zip, phone;
//If possible i would like 1st 3 in 1 TD and last 5 in 1 TD
<?php
trim($searchterm);
if (!$searchtype || !$searchterm)
{
echo "<p align=center><b>You have not entered search details. Please go back and try again.</b></p>";
exit;
}
/* Connecting, selecting database */
@ $db = mysql_connect("db_host", "db_user", "db_pass"
or die("Could not connect"
mysql_select_db("churches" or die("Could not select database"
/* Performing SQL query */
$query = "SELECT * FROM church order by 'name' asc";
$result = mysql_query($query) or die("Query failed"
$num_results = mysql_num_rows($result);
print "<p><b>Your search produced ".$num_results." matches.</b></p>";
/* Printing results in HTML */
print "<table border=1 cellspacing=0 cellpadding=2 width=750 align=center>\n";
print "<tr>\n";
print "<td bgcolor=#0099CC colspan=3><p><b>Organization</b></p></td>\n";
print "<td bgcolor=#0099CC colspan=5><p><b>Information</b></p></td>\n";
print "</tr>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
if ($searchterm = '%"nameof"%');
print "<tr>\n";
foreach ($line as $col_value) {
print "\t\t<td height=30><p><font size=1>$col_value</font></p></td>\n";
}
print "\t</tr>\n";
}
print "</table>\n";
/* Free resultset */
mysql_free_result($result);
/* Closing connection */
mysql_close($db);
?>
This script actually calls the whole table rather then meeting the search parameters. Can someone help with altering the php script to actually do what I want it to, find matches for searchtype and searchterm?
Thanks - Desperate
This is from form.htm
<form action="results.php" method="post">
<p>Search by:
<select name="searchtype">
<option value="name">Organization Name
<option value="denomination">Denomination
<option value="city">City
</select>
Keyword:
<input type="text" name="searchterm">
<input type="submit" value="Search">
</p>
</form>
This is from results.php
//feild names if you need them;
//name, pastor, denomination, address, city, state, zip, phone;
//If possible i would like 1st 3 in 1 TD and last 5 in 1 TD
<?php
trim($searchterm);
if (!$searchtype || !$searchterm)
{
echo "<p align=center><b>You have not entered search details. Please go back and try again.</b></p>";
exit;
}
/* Connecting, selecting database */
@ $db = mysql_connect("db_host", "db_user", "db_pass"
or die("Could not connect"
mysql_select_db("churches" or die("Could not select database"
/* Performing SQL query */
$query = "SELECT * FROM church order by 'name' asc";
$result = mysql_query($query) or die("Query failed"
$num_results = mysql_num_rows($result);
print "<p><b>Your search produced ".$num_results." matches.</b></p>";
/* Printing results in HTML */
print "<table border=1 cellspacing=0 cellpadding=2 width=750 align=center>\n";
print "<tr>\n";
print "<td bgcolor=#0099CC colspan=3><p><b>Organization</b></p></td>\n";
print "<td bgcolor=#0099CC colspan=5><p><b>Information</b></p></td>\n";
print "</tr>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
if ($searchterm = '%"nameof"%');
print "<tr>\n";
foreach ($line as $col_value) {
print "\t\t<td height=30><p><font size=1>$col_value</font></p></td>\n";
}
print "\t</tr>\n";
}
print "</table>\n";
/* Free resultset */
mysql_free_result($result);
/* Closing connection */
mysql_close($db);
?>