Languages :: PHP :: Site Search |
|||
| By: FiatLink |
Date: 09/03/2003 00:00:00 |
Points: 300 | Status: Answered Quality : Excellent |
|
Hello, I would like to impliment a site search on my web server. Could somone help me with this. Thanks |
|||
| By: TheFalklands | Date: 09/03/2003 09:31:00 | Type : Comment |
|
| look at this page, there are some ready to use scripts: <A HREF="http://php.resourceindex.com/Complete_Scripts/Searching/Searching_Your_Web_Site/">http://php.resourceindex.com/Complete_Scripts/Searching/Searching_Your_Web_Site/</a> |
|||
| By: VGR | Date: 10/03/2003 07:13:00 | Type : Comment |
|
| 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. |
|||
| By: FiatLink | Date: 10/03/2003 10:02:00 | Type : Comment |
|
| 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 <A HREF="http://www.fibdev.com">http://www.fibdev.com</a> 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. |
|||
| By: FiatLink | Date: 14/03/2003 12:13:00 | Type : Comment |
|
| 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. |
|||
| By: VGR | Date: 14/03/2003 18:25:00 | Type : Comment |
|
| 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 |
|||
| By: FiatLink | Date: 16/03/2003 09:38:00 | Type : Comment |
|
| 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> <input type="text" name="SearchString" size="16"> <input type="submit" value="Go" name="Button1"> register_globals is On. |
|||
| By: VGR | Date: 16/03/2003 17:17:00 | Type : Answer |
|
| 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'--> "; // 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 "; // 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. "; ?> |
|||
| By: FiatLink | Date: 17/03/2003 12:52:00 | Type : Comment |
|
| 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. :) |
|||
| By: FiatLink | Date: 12/04/2003 01:50:00 | Type : Comment |
|
| I never did get this working. Thank you for trying. |
|||
| By: VGR | Date: 12/04/2003 02:02:00 | Type : Comment |
|
| why ? it's crystal clear... what are the errors ? |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








