Site Search

Hello,

I would like to impliment a site search on my web server.
Could somone help me with this.

Thanks
LVL 3
fibdevAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nikottoCommented:
look at this page, there are some ready to use scripts:
http://php.resourceindex.com/Complete_Scripts/Searching/Searching_Your_Web_Site/
0
VGRCommented:
other solution : YOU know WHERE in your site (DB ?) you can find relevant data, and YOU build a simple HTML FORM for people to enter keywords, dates and such, and YOU run/display the query and it's results.
If you only want to provide "full-text" search on static pages on all of your site, then use the provided link above or any free search module.
0
fibdevAuthor Commented:
I've looked into the search modules and I think I'm leaning toward a database driven solution.  My site is of moderate size, so it won't take me long to index it.  I am new to php and will need help setting up.  I think for now, I just want to provide keyword searches from a simple textbox and button form.  See http://www.fibdev.com for example.  I've created the form already.  I just need help with the php and how I should set up the table.  Here is the information I would like to display.

Link
Page Title
A few limes of text

Next result...

Next result...

Let's call the table "sitesearch"  Thanks up front for your help.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

fibdevAuthor Commented:
I still need help with this... Is anyone out there.  I'm new to php and would like a script to queary this table and display these results.
0
VGRCommented:
so let me summarize :
1) you have a 100% static website
2) you intend to build a small DB to hold the "keywords" and page references where they appear
3) then you've the FORM that enables the user to enter any combiantion of keywords, or only one (simplier)
4) you need a small PHP source to take the data from the FORM, query the DB accordingly, and return the pages' references in
0
VGRCommented:
so let me summarize :
1) you have a 100% static website
2) you intend to build a small DB to hold the "keywords" and page references where they appear
3) then you've the FORM that enables the user to enter any combiantion of keywords, or only one (simplier)
4) you need a small PHP source to take the data from the FORM, query the DB accordingly, and return the pages' references in a list

Am I right ?

Then I need to see your FORM (for fields' names and ACTION= and METHOD=)
Also tell me if you use register_globals=On or Off
And finally what philosophy of search you need so that I can build the DB layout for you

If ever you add a new page or modify somepages, you'll need a mechanism to update the "index/search" DB
0
fibdevAuthor Commented:
I am able to modify the database.  My host provides me with a very useble Database Manager.  The form is simple.

<form method="POST" action="/sitesearch/search.php" style="border-right: 1 solid #647C88; border-bottom: 1 solid #647C88">
            <p style="margin-left: 8">
            <font face="Century Gothic" size="1" color="#647C88">Search for</font>
            <br>
            <input type="text" name="SearchString" size="16">&nbsp;
<input type="submit" value="Go" name="Button1">

register_globals is On.
0
VGRCommented:
yes, simple indeed :D

good good good

Just make sure that your script generating the form has session_start(); at the beginning

Build this script now :
----------------search.php ----------------
<?
session_start();
//tracking problems beforehand ;-)
echo "<!--transmitted search value = '$SearchString'--><BR>";
// note also that SearchString could have been addslashes()-ed, depending on your magic quoting configuration, so may-be a call to stripslashes() will be required.

// ok, now query the DB
require_once("database_def.inc.php"); // $dbHost, $dbName, etc
$linkID=mysql_connect("$dbHost","$dbLogin","$dbPassword") or die ("bad connect".mysql_error());
mysql_select_db($dbName,$linkID) or die ("bad select db. ".mysql_error());

// if you want the exact string :
$query="SELECT * FROM yourtable WHERE yourkeywordfield LIKE '%SearchString%';"; // [ORDER BY]
// if you want a "any word within" search :
// explode on ' ', implode on '%\' OR \'%', you got the picture

// effectively query DB
$result=mysql_query($query,$linkID) or die ("bad query '$query' : ".mysql_error());

// now display results
if (mysql_num_rows($result)>0) {
  while ($res=mysql_fetch_array($result)) {
    // get data
    $locID=$res["id"];
    $locfield1=$res["field1"]; // your table layout commands here
    // display result
    echo "result: $locfield1<BR>"; // ditto, please precise.
  } // while results
  // here whatever after the results, like echo "X results found"... or a mysql_close() - not necessary
} else echo "No Results.<BR>";
?>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fibdevAuthor Commented:
I think I can work with this.  Thank you.

I will impliment this tommorow and award the points.  I shouldn't need anything else, but we will see.

:)
0
fibdevAuthor Commented:
I never did get this working.  Thank you for trying.
0
VGRCommented:
why ? it's crystal clear... what are the errors ?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.