Forum Moderators: coopster

Message Too Old, No Replies

Search system

What'ss the best solution for a website search system

         

crow976

3:07 pm on Aug 13, 2003 (gmt 0)

10+ Year Member



Hi people,

I want to get a search system on my website so that users can find some content in my .php/.html files. Is there a good php solution available? Is php any good for that sorta thing or I should go for something else?

waiting for your suggestions...

my webserver supports php, cgi, perl... but I'd really like a php solution!

panic

6:09 pm on Aug 13, 2003 (gmt 0)

10+ Year Member



Well, are the files that you want to be able to search through static or dynamic?

Either way, it can be done with PHP, but there's a bunch of different ways to go about it.

-panic

jatar_k

6:10 pm on Aug 13, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what about phpdig?

vincevincevince

6:11 pm on Aug 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



how are your pages delivered? from the database dynamically, or as static pages?

crow976

6:52 pm on Aug 13, 2003 (gmt 0)

10+ Year Member



the site is dynamic using a mysql database. It's a website for an auctioneer, so we display the future sales sorted by date... but some/most sales also have a .html file associated to it with information about what is going to be sold, where the even takes place and other various information. It would be useful for the users to have a search feature so that they can search lets say for "John Deer" and have a list of sales which have that item for sales..

but the links to the various html documents about the sales are generated by php from the database (each entry in the database has a field with filename.html ... or empty if there's no text)

you can see the actual site here if you want to have a better idea of what i mean
<snip>

site is in french, but you'll get the idea...
when you click on the date, you get the html text file.

[edited by: jatar_k at 6:55 pm (utc) on Aug. 13, 2003]
[edit reason] no urls thanks [/edit]

crow976

6:55 pm on Aug 13, 2003 (gmt 0)

10+ Year Member



im sorry, you have to click on [Texte] to get the text, not the date...

when a search engine searches a .php file, does it get the output after php has executed it?

jatar_k

6:56 pm on Aug 13, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



does it get the output after php has executed

yes it does, given that php is server side the client, regardless of who or what it is, will get the html content only

panic

8:41 pm on Aug 13, 2003 (gmt 0)

10+ Year Member



Use a MySQL query to pull the results.

-panic

vincevincevince

12:47 am on Aug 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



the most basic search facility is to use a mysql query ending in "WHERE description LIKE '%$searchterm%';" which would return all records from the database where the word $searchterm is within the description.

crow976

2:39 pm on Aug 14, 2003 (gmt 0)

10+ Year Member



yea okay, but what I'd mostly like the system to search is a bunch of .html files... not database entries.

waitman

5:57 pm on Aug 14, 2003 (gmt 0)

10+ Year Member



phpdig is pretty good, i recently used it to build a "competitor's site" report for a client.

However, it doesn't care about any of the meta tags, just the page content. So I made a quick and dirty script to fetch that stuff and put it in a text file

<?php

$conn = @mysql_connect('thehost','username','password');
$db = @mysql_select_db('phpdig_database');

$sql = "SELECT file,path FROM spider";
$result = @mysql_query($sql,$conn);
while ($row=@mysql_fetch_array($result))
{
$url='inserturlhere'.$row[1].$row[0];
$html=@join('',@file($url));
$html = str_replace("\n","",$html);
$html = str_replace("\r","",$html);
preg_match('/<title>(.*)<\/title>/Usi', $html, $title);
$thistitle = $title[1];
$keys = @get_meta_tags($url);

echo $url."\t".$thistitle."\t".$keys['keywords']."\t".$keys['description']."\n";
}
@mysql_free_result($result);
@mysql_close($conn);
?>

just do something like

php -q fetchmeta.php > meta.txt

this could probably be better integrated right into phpdig, but i didn't have the time or inclination for the report.

also, you might check out aspseek.

it is reasonably good with fast results. i had trouble with the php modules provided, ended up dumping them, and used a system call to the cgi from my php script- seemed to work ok for my project.

take care,

waitman

6:03 pm on Aug 14, 2003 (gmt 0)

10+ Year Member



i take that back about aspseek, i didn't use a system call, just pulled the results like this

$content = str_replace('/cgi-bin/s.cgi','search2.html',@join('',@file('http://{domain omitted}.com/cgi-bin/s.cgi?'.$q)));

hope that helps.

lorax

6:41 pm on Aug 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I use an open source product called DGS Search. Will search static files and/or MySQL databases. You can exclude what you don't want it to search and it's snappy quick.

panic

6:52 pm on Aug 14, 2003 (gmt 0)

10+ Year Member



I still say your best bet would be just to import that data from the HTML files into your MySQL database (since you've already got it up and running anyhow).

A MySQL query is probably going to be a lot faster than opening up a whole directory of HTML files... not to mention that it wont put as much strain on your server.

-panic

grey259

5:34 am on Aug 16, 2003 (gmt 0)

10+ Year Member



Have you checked out PHPAuction? There's a GPL version, which is free and already has many of the features you are trying to build.