Adding a search feature

I am looking to add a search box to my website where if a person puts in what they want, the results will come on another page with the results. I had google search on there and now it is not working. it is just coming up blank.

Can anyone lead me to a tutorial that shows how to do this? The site runs on php/mysql

Thanks

Can you provide the url of the site.

Why would you need that?

Descriptions of problems are often incomplete. Rather than waste time trying to work out what the user is actually doing it is a lot easier to look at what they are going. You say you are using google search which usually involves putting a javascript code snippet on the page but it doesn’t sound like that is the case. You might be using google custom search, using your own search box and using server side code to get a xml stream back to be formatted for display. A url would have told me.

Ok, didnt know that. Just dont get why it would work a week ago and all of a sudden it dont now.

url is

http://allfoodequip.com

you can see the search box down the middle of the page.

Got getting anything when I use the URL

its up.

You are adopting an approach I am not familiar with

Have you seen https://developers.google.com/custom-search/docs/element?

I usually think of it in two ways.

Firstly have the everything done by google javascript client side or two do things server side.

The first simple needs something like

<!-- Put the following javascript before the closing tag. –>
<script>
(function() {
var cx = ‘123:456’; // Insert your own Custom Search engine ID here
var gcse = document.createElement(‘script’); gcse.type = ‘text/javascript’; gcse.async = true;
gcse.src = (document.location.protocol == ‘https’ ? ‘https:’ : ‘http:’) +
//www.google.com/cse/cse.js?cx=’ + cx;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(gcse, s);
})();
</script>

<!-- Place this tag where you want both of the search box and the search results to render –>
<gcse:search></gcse:search>

on the web page.

The second just needs a standard input form on the page, no google javascript at all. The action of form calls a server side routine, in your case results.php. The server side code queries google get an xml data stream back which can then be formatted for display.

That been said I get the impression that results.php is being called correctly. This would suggest that something is wrong server side.

The query to google should be

http://www.google.com/search?start=1&num=20&q=equipment&client=google-csbe&output=xml_no_dtd&cx=004179649851625589392:i15z5lqz9uw

but this does not return anything. It could be that the custom search is not configured correctly.

I would go into custom search and use the preview.

David,

You can install the Google search or you can apply a third party search script on your site.

Here is a php script that you can download,

https://www.esyntropy.com/php-flat-file-search-script/

It allows you to specify directories that you do not want to search, comes with a customizable template and you can make usability tweaks like displaying the number of search results per page.

Hope that helps,

Shawn