Hello,
I have a search script that consists of two pages. One is a search.php page and the other is results.php On the search.php page, one types in a name and it pulls the business info off my MySQL database and displays it is the results.php page. The script prevents someone from entering nothing which would show the entire database. However, if someone enter a single letter- say "A" it shows every business that has the letter A in it. Is there a way to set a minimum of three letters to search the database? In other words, if someone typed "C" or "GI" it would reject their search and tell them they need to have a minimum of three chracters in order to search. I am a newbie and tried messing with the elseif command but couldn't get it working. Appreciate any info!
Here is my results.php script:
//connect to mysql
$search=$_GET["search"];
if(!$search)
{
echo("Please Input Something To Search For");
}
else
{
$result = mysql_query("SELECT * FROM table WHERE name LIKE '%$search%'");
//grab all the content
while($r=mysql_fetch_array($result))
{
$name=$r["name"];
$business=$r["business"];
echo "$name- $business<br>";