You forgot to enter a search term"; exit; } // Otherwise we connect to our Database mysql_connect("localhost", "munsing_karaoke", $pass) or die(mysql_error()); mysql_select_db("munsing_songbooks") or die(mysql_error()); // We preform a bit of filtering $songquery = strtoupper($songquery); $songquery = strip_tags($songquery); $songquery = trim ($songquery); $songquery = addslashes($songquery); $keywords = explode(" ", $songquery); $keyCount = 0; foreach ($keywords as $keys) { if ($keyCount > 0){ $search_sql .= " AND"; } $search_sql .= " Name LIKE '%$keys%'"; ++$keyCount; } $sortby = $_GET["sortby"]; $sql = "SELECT * FROM karaoke WHERE artist LIKE '%$keys%' OR title LIKE '%$keys%' OR songnumber LIKE '%$keys%' ".$sqlExtra; //Now we search for our search term, in the field the user specified $data = mysql_query($sql); //And we display the results if ($songquery !== "") { echo ""; } while(($result = mysql_fetch_array( $data )) !== false) { $i++; $artist = $result['artist']; $artist = strtoupper($artist); $artist = strip_tags($artist); $artist = trim ($artist); $artist = str_replace("'", "'", $artist); $title = $result['title']; $title = strtoupper($title); $title = strip_tags($title); $title = trim ($title); $title = str_replace("'", "'", $title); $songnumber = $result['songnumber']; echo ""; echo ""; echo ""; echo ""; echo "\n"; } echo "
artist title song number
".$artist."".$title."".$songnumber."
"; //This counts the number or results - and if there wasn't any it gives them a little message explaining that if ($searching == "yes"){ $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "

Sorry, but we can not find an entry to match your query

"; } mysql_close(); } } ?>