Help with search engine
Posted: Fri Mar 26, 2010 6:05 pm
hey i got need a little help with this code i made for a search engine i checked every thing is ok with the database for it and yet i just can't get it to search oh and insted of getting an error and what line the error was on i just get
half of my search.php code. here is the search.php code:
half of my search.php code. here is the search.php code:
Code: Select all
<php?
session_start();
include "connect.php";
$button = $_GET['submit'];
$search = $_GET['search'];
{
if (!$button)
echo "You didn't submit a keyword.";
}
else
{
if (strlen($search)<=2);
echo "Search term too short.";
else
{
echo "you searched for <b>$search</b> <hr size='1'>";
mysql_connect("localhost","root","")
mysql_select_db("asearch");
{
$search_exploded = explode(" ",$search);
foreach($search_exploded as $search_each)
{
$x++;
if ($x=1)
$construct .= "keywords LIKE '%$search_each%'";
else
$construct .= "OR keywords LIKE '%$search_each%'";
}
{
$construct = "SELECT * FROM asearch WHERE $construct";
$run = mysql_query($construct):
if mysql_num_rows($run)=0)
ehco "No results found";
else
}
echo "$foundnum results found!<p>";
while ($runrows = mysql_fetch_assoc($run))
{
$title = $runrow['title'];
$desc = $runrow['description'];
$url = $runrow['url'];
echo "
<b>$title</b><br>
$desc<br>
<a href-'$url'>$url<p>
";
}
}
}
?>