search data

Do you have questions regarding other database enginges (not MySQL) -- ask here!

Moderators: macek, egami, gesf

haamid
New php-forum User
New php-forum User
Posts: 6
Joined: Sat Aug 07, 2010 10:54 am

search data

Postby haamid » Sun Aug 08, 2010 4:28 am

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>
";
}


}

}
}
?>

Return to “Other Database Engines”

Who is online

Users browsing this forum: No registered users and 1 guest