SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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
    Thanks In Advance

    David

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you provide the url of the site.

  3. #3
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why would you need that?
    Thanks In Advance

    David

  4. #4
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, didnt know that. Just dont get why it would work a week ago and all of a sudden it dont now.

    url is
    Code:
    http://allfoodequip.com
    you can see the search box down the middle of the page.
    Thanks In Advance

    David

  6. #6
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got getting anything when I use the URL

  7. #7
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its up.
    Thanks In Advance

    David

  8. #8
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are adopting an approach I am not familiar with

    Have you seen https://developers.google.com/custom.../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...92: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.

  9. #9
    SitePoint Addict bronze trophy
    Join Date
    Mar 2013
    Location
    Oneonta, NY
    Posts
    307
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •