• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Need help with my PHP search script!!??

D

DAZZ

Guest
#1
Hi, I have a search script in PHP which searches a MYSQL DB table for websites, and what's on them. The current setup is:

'number' the number of the website
'url' the url of the website
'contains' this is where the search script searches in, and its whats on the website.

The searching works great, but I need something to be added to it....

For example, I have the the sites http://www.yahoo.com/ and http://www.php.net/ in the databas, setup like so...

'1' 'http://www.yahoo.com/ 'search, good search engine, the.greatest.search, good.place'

'2' 'http://www.php.com/ 'php, php makers, great.info'

As you see, each 'keyword' is seporated by a comma ',' And when someone searches for, let's say "good"....this would show up...

SITE NUMBER '1'
URL: http://www.yahoo.com
Contains: search, good search engine, the.greatest.search, good.place

it displays that, because the word good is in the contains field of this website

But what im wanting to do is to make it so when someone searches for "good" this will come up...

SITE NUMBER '1'
URL: http://www.yahoo.com/
Contains: good search engine, good.place

What happens is, it takes away everything that doesnt contain "good" in it, it takes away 'search, the.greatest.search'

I know it would be possible, because of the commas ',' just do something with them to make this possible..

Im really new to php, so i dont know anything....

PLease try to help me out, this is important, thank you!!!

If you don't understand something, please tell me, I really need this working!!

Thanks
 
D

DAZZ

Guest
#3
im really new to PHP, and i really wouldnt know where to start with that, could i just send you my entire PHP search script, and u can look it over??

pleeease
 
#6
Try this before printing $replaced. (Untested code)

PHP:
$keyarr = explode($replaced, ",");
$replaced = "";
for(int $i=0;$i<sizeof($keyarr);$i++){
	if(stristr($keyarr[$i], $search)){
		$replaced .= $keyarr[$i] . ",";
	}
}
// Remove trailing comma
$replaced = substr($replaced, 0, strlen($replaced) - 2));
 
D

DAZZ

Guest
#7
i get...

Parse error: parse error, unexpected T_VARIABLE, expecting ';' in /www/www2/123/search.php on line 73
:huh: :huh:
 
#10
Umm, my bad. Skip "int ".

PHP:
$keyarr = explode($replaced, ",");
$replaced = "";
for($i=0;$i<sizeof($keyarr);$i++){
    if(stristr($keyarr[$i], $search)){
        $replaced .= $keyarr[$i] . ",";
    }
}
// Remove trailing comma
$replaced = substr($replaced, 0, strlen($replaced) - 2));
I told you I hadn't tested the code! :p (still haven't)
 

Members online

No members online now.

Latest posts

Latest profile posts

Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,961
Messages
673,239
Members
89,013
Latest member
Pdawgintown