My search engine...
Posted: Sat Jun 10, 2006 3:24 pm
Jcart | Please use
This is my search engine. It's obvious I connect to my database before this to select the objects that contain keywords. Now for some reason when ever I type two keywords as my search and an object has those two, the object isn't displayed. I've been racking my brains all day trying to figure out why it doesn't work.
If you see anything wrong with the code, or know of a better way to code this, please spot it out for me, I'd very much appreciate it.
Thanks.
Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
while ($row = mysql_fetch_array($result)) {
//keywords handling
if ($row['keywords'] != "") {
$keywords = $row['keywords'];
} else {
$keywords = "";
}
$hit = 0;
$_GET['search'] = trim($_GET['search']);
$search = explode(" ", $_GET['search']);
$keywords = explode(",", $keywords);
$l = 0;
$usrloop = 0;
for ($l=0; $keywords[$l] != ""; $l++) {
$keywords[$l] = trim($keywords[$l]);
echo "<font color=red>".$keywords[$l]."</font>".",";
for ($usrloop=0; $search[$usrloop] != ""; $usrloop++) {
$search[$usrloop] = trim($search[$usrloop]);
echo $search[$usrloop].",";
if ((strtoupper($search[$usrloop]) == strtoupper($keywords[$l]))) {
$hit++;
}
}
}
$display_block[$hit] .= "My objects information";
echo $hit;
}
?>
<?
for ($length=count($display_block); $length > 1; $length-=1) {
echo "<table width=100% border=0 cellspacing=0 cellpadding=0 align=center><tr><td>".$display_block[$length-1]."</td></tr></table>";
}
?>
<?
include ("jscontrol.php");
?>If you see anything wrong with the code, or know of a better way to code this, please spot it out for me, I'd very much appreciate it.
Thanks.
Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]