Database search function
Posted: Sat May 03, 2008 10:28 am
I have a search box that is basically working, but it needs some tweaking.
I'd like the results page to echo, "Sorry, no results matched." or something
like that when there are no results.
This is the form for the text box:
This is the handle_keywords1.php that handles it:
I'd like the results page to echo, "Sorry, no results matched." or something
like that when there are no results.
This is the form for the text box:
Code: Select all
<form action="handle_keywords1.php" method="post">
<b><p>Search Checks:</b> <input type="text" name="keyword" size="20" maxlength="40" /></p>
<dd align="center"><input type="submit" name="submit" value="Search" /></dd>
</form>
Code: Select all
<?php
include('../../misc.inc');
$cxn = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
mysql_select_db($database);
$database = "voipvide_checks";
$upperKeyword = strtoupper($keyword);
$query = "SELECT * FROM fourchecks WHERE upper(name) like '%$upperKeyword%' ORDER BY Name";
$result = mysql_query($query)
or die ("Couldn't execute query.");
/* Display results in a table */
echo "<center><table cellspacing='10'>";
echo "<tr><td colspan='3'><hr /></td></tr>";
while($row = mysql_fetch_assoc($result))
{
extract($row);
echo "<tr>\n
<td width='300'><img src='$BigImage' border ='0' alt='$Name Bank Checks'><P><font size='2'>
<a href='$Link'>$Name BANK CHECKS</a><br>
</td>\n
<td width='100'></td>\n
</tr>\n";
echo "<tr><td colspan='2'><hr /></td></tr>\n";
}
echo "</table></center>\n";
?>