Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

Site Search

Hello,

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

Thanks
0
fibdev
Asked:
fibdev
  • 5
  • 5
1 Solution
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now