Skip to main content
Known Participant
January 3, 2011
Answered

Need a "simple" site search...similiar to the one on this page.

  • January 3, 2011
  • 1 reply
  • 909 views

HELP! I have given up figuring this out on my own and need an expert to point me in the right direction.

I have tried and tried to make a site search and the only one I can get to work is the one I "creatively borrowed" on the web. It is a google type search that has ads. I want something that is ad free and simple. Can anyone please help. I have php enabled on my server. I just want the box and the magifying glass icon only. Then when a user types in their keywords, it brings the results into a seperate page.

Thank you! Donna

This topic has been closed for replies.
Correct answer bregent

Is this a dynamic or static site you are talking about?

If a dynamic site, you can often allow users to search by querying the database that the dynamic content is stored in. If it's static, then you need to either build or buy an engine. This will crawl your site and build an index in a database. The database links the pages in your site to search terms.

Obviously we can't really help without knowing more about your site and your capabilities.

You might want to check out something like Zoom - http://www.wrensoft.com/zoom/ and see if that meets your needs.

1 reply

January 3, 2011

Content is stored in database. Create a form with method="GET" action results.php and input type="text" id="search_term".

On results.php declare the variable for the form value "search_term"

$search_term = $_GET['search_term'];

Then create a query to select whatever form your database table where the table field is LIKE the submitted search term.

SELECT * FROM table WHERE field1 LIKE ‘%$search_term%’

do { } while to loop the query results where query rows => 1 else show message that no search results were returned. Sanitize variables to prevent injection attack on your database.

Ironically, there is plenty of information on the subject if you search google for the term: php search form tutorial.

DS8108Author
Known Participant
January 4, 2011

Ugh..I pasted the wrong code. Here is my search form: It can be found at www.arkbankers.org/search.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search ABA</title>
</head>

<body>

<form name="searchsite" method="get" action="arkbankers.org/searchresults.html" target="_top">

   <strong>Site Search<strong><br />
      <input type="text" size="25" name="searchvalue"> <input type="submit" name="submit" value=" Search "><br />
   </strong></strong>
</form>

</body>
</html>

bregentCorrect answer
Participating Frequently
January 4, 2011

Is this a dynamic or static site you are talking about?

If a dynamic site, you can often allow users to search by querying the database that the dynamic content is stored in. If it's static, then you need to either build or buy an engine. This will crawl your site and build an index in a database. The database links the pages in your site to search terms.

Obviously we can't really help without knowing more about your site and your capabilities.

You might want to check out something like Zoom - http://www.wrensoft.com/zoom/ and see if that meets your needs.