Here is a search that I am making to see my problem view this: [url]http://www.d-top.org/search/?q=a&Submit=Search
Now take one of the descriptions, and mess the words up a little, in the search box it should find what you searched for, but it doesn’t. Any idea how to make my code do that?
You also can’t take a keyword, and mix it with a something that isn’t a key word. For example Newgrounds is on the list for the title, and the one of the keywords for it is flash. You can’t search for “newgrounds flash”, because it will find nothing.
Here is the code:
[code=php]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta name=”robots” content=”noindex,nofollow”>
<link rel=”stylesheet” type=”text/css” href=”style.css”>
<title>Finder</title>
</head>
<body OnLoad=”document.form.q.focus();”>
<p> </p>
<center>
<a href=”/search/”><img alt=”finder” src=”images/logo_finder.gif”></a><sup>Beta</sup><br>
<form name=”form” action=”<?$PHP_SELF?>” method=”get”>
<input type=”text” name=”q” />
<input type=”submit” name=”Submit” value=”Search” /><br>
<sup><a href=”addself.php”>Submit A Site</a></sup>
</form>
</center>
<?php
// Get the search variable from URL
$var = @$_GET[‘q’] ;
$trimmed = trim($var); //trim whitespace from the stored variable
// rows to return
$limit=10;
// check for an empty string and display a message.
if ($trimmed == “”)
{
exit;
}
// check for a search parameter
if (!isset($var))
{
echo “<p>We dont seem to have a search parameter!</p>”;
exit;
}
//connect to your database ** EDIT REQUIRED HERE **
mysql_connect(“localhost”,”dtoporg_dtop”,”abc123″); //(host, username, password)
//specify database ** EDIT REQUIRED HERE **
mysql_select_db(“dtoporg_search”) or die(“Unable to select database”); //select which database we’re using
// Build SQL Query
$query = “SELECT * FROM search WHERE CONCAT(urltitle,description,keywords) LIKE ‘%$trimmed%’
ORDER BY keywords, description, urltitle”;
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
// next determine if s has been passed to script, if not use 0
if (empty($s)) {
$s=0;
}
echo ‘<div class=”content”>’;
// get results
$query .= ” limit $s,$limit”;
$result = mysql_query($query) or die(“Couldn’t execute query”);
$count = 1 + $s;
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
// display what the person searched for
echo “<p>Your search for <b>” . $var . “</b> found ” . $numrows . ” results</p>”;
// now you can display the results returned
while ($row= mysql_fetch_array($result)) {
$url = $row[“url”];
$urltitle = $row[“urltitle”];
$menu1 = $row[“menu1”];
$description = $row[“description”];
$keywords = $row[“keywords”];
$count = 1 + $s ;
echo ‘<p><b><a href=”‘.$url.'”>’. $urltitle .'</a></b> Category: ‘. $menu1 .'<br>’. $description.'<br><span class=”url”>’.$url.'</span>’;
$count++ ;
}
$currPage = (($s/$limit) + 1);
//break before paging
echo “<p> </p>”;
// next we need to do the links to other results
if ($s>=1) { // bypass PREV link if s is 0
$prevs=($s-$limit);
print ” <a href=”$PHP_SELF?s=$prevs&q=$var”><<
Prev 10</a>  ”;
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
// check to see if last page
if (!((($s+$limit)/$limit)==$pages) && $pages!=0) {
// not last page so give NEXT link
$news=$s+$limit;
echo “ <a href=”$PHP_SELF?s=$news&q=$var”>Next 10 >></a>”;
}
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo “<p>Showing results $b to $a of $numrows</p>”;
?>
</div>
</body>
</html>