A
Anonymous
Guest
Please check error .
__________________________
index
____
<html>
<form action="search.php" method="get">
<font face="sans-serif" size="5">
<center>
my search.<br>
<input type="text" size="50" name="search"> <input type="submit" name="submit" value="search">
</center>
</font>
</form>
</html>
_________________________
search
____
<?php
//get data
$button = $_GET['submit'];
$search = $_GET['search'];
if (!$button)
echo "You did`t submit a keyword.";
else
{
if (strlen($search)<=2)
echo "search term too short.";
else
{
echo "You search for $search<hr size='1'>";
mysql_connect("localhost","root","");
mysql_select_db("phpacademy");
{
$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%'";
}
}
//here
$construct = "SELECT * FROM searchengine WHERE $construct";
$run = mysql_query ($construct);
$foundnum = mysql_num_rows($run);
if ($foundnum==0)
echo "NO result found.";
else
{
echo "$foundnum results found!<p>";
while ($runrows = mysql_fetch_assoc($run))
{
//get data
$title = $runrows['title'];
$desc = $runrows['desc'];
$url = $url['title'];
echo "
<b>$title</b><br>
$desc<br>
<a href='url'>$url</a><p>
";
}
}
}
}
?>
__________________________
index
____
<html>
<form action="search.php" method="get">
<font face="sans-serif" size="5">
<center>
my search.<br>
<input type="text" size="50" name="search"> <input type="submit" name="submit" value="search">
</center>
</font>
</form>
</html>
_________________________
search
____
<?php
//get data
$button = $_GET['submit'];
$search = $_GET['search'];
if (!$button)
echo "You did`t submit a keyword.";
else
{
if (strlen($search)<=2)
echo "search term too short.";
else
{
echo "You search for $search<hr size='1'>";
mysql_connect("localhost","root","");
mysql_select_db("phpacademy");
{
$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%'";
}
}
//here
$construct = "SELECT * FROM searchengine WHERE $construct";
$run = mysql_query ($construct);
$foundnum = mysql_num_rows($run);
if ($foundnum==0)
echo "NO result found.";
else
{
echo "$foundnum results found!<p>";
while ($runrows = mysql_fetch_assoc($run))
{
//get data
$title = $runrows['title'];
$desc = $runrows['desc'];
$url = $url['title'];
echo "
<b>$title</b><br>
$desc<br>
<a href='url'>$url</a><p>
";
}
}
}
}
?>