Jump to content

searching your own website?


kellz

Recommended Posts

I saw lots of websites have the search thing that only searches their own website for keywords and I tried to make one, but, not to my surprise it didn't go as planned for long^^

 

How do the "real" search thingies work? like on this site  ??? i want 1!  :-[

Link to comment
https://forums.phpfreaks.com/topic/77800-searching-your-own-website/
Share on other sites

you would have to redesign your cms or apply additional steps.

if your cms stores all the content in a databasing of some sort you can use a query with the "like" type to get what you want.

If you cms does not store your data like so you will need to self index  your pages exactly like google does and then use those indexes as your search pool.

 

It can be done, but if you don't have a strong cms behind it forget it cause selfindexing your site is difficult.

i guess that goes this way..

 

sample you use this key words 

 

$yourquery = 'select * from table where 1=1  ';
$var = trim('am i  teng');
$array = explode($var);
$srch = '';
foreach($array as $val){
$srch .= "  OR yourfieldhere  like '%".$val."%'";
}

if ($srch != $srch){
      mysql_query ($yourquery.$srch);//do other stuff here
}
else{
//some stuff here
}

simple but should give an idea !

Yes I think the most simple but causes alot more data storage is keywords as said above. example...

 

1.Create database table called keywords_search_site create fields as follows

 

ID

keyword

description

link

 

2. create the form for searching

 

3. Create the processing code for the search which should break up the search words into an array and search the database for each word of the array.

 

4. Show the results on screen as...

 

Description and then a link to the page which holds what they looked for.

 

 

Hope that helps the theory side of it. If you want any code mucking up just ask.

 

 

Regards

 

Distant Storm

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.