Is it typical, or is it something wrong with the code?
If you get to the search page from another page via submitted form, and if you had a blank form, you get “no keywords” message.
Now if you are on the search page already, and you hit “search” button with a blank input field, you no longer get “no keywords” message but rather all of the records are being displayed. Given that I have over 4000 records, it is definitely not something I am looking to do.
Here is the code, maybe it is something that should be adjusted there?…
[code=php]
<?php
if (isset($search))
{
mysql_connect(APP_DB_HOST, APP_DB_USER, APP_DB_PASSWORD) or die (“Problem connecting to Database”);
$srch = “%”.$search.”%”;
$query = “SELECT * FROM table WHERE field_one LIKE ‘%$search%’ OR field_two LIKE ‘%$search%'”;
$result = mysql_db_query(“db_mydomain_com”, $query);
if (mysql_num_rows($result)>0)
{
echo “<h4>SEARCH RESULTS</h4>”;
echo “<table>”;
echo “n”;
while ($rtr = mysql_fetch_array($result)) {
// START WHILE LOOP
$one = $rtr[“field_one”];
$two = $rtr[“field_two”];
echo “<tr>n”;
echo “<td class=”small”>$one</td>n”;
echo “<td class=”small”>$two</td>n”;
echo “</tr>n”;
}
// STOP WHILE LOOP
echo “</table>n”;
echo “n”;
}
else {
echo “there were no results found”;
}
}
else {
echo “there were no keywords defined”;
}
?>