Jump to content

Archived

This topic is now archived and is closed to further replies.

Bavilo

Search Function

Recommended Posts

Hello,

I was thinking about adding a search field on my site. A field where i just enter some text, click search, and then a new page pops up with the google results of that query. What i need to know is how to append the following: site:http://mysite.com so it actually calls for "blah blah site:http://mysite.com" Can i do this using php?

Thanks
Mike

Share this post


Link to post
Share on other sites
[!--quoteo(post=358064:date=Mar 24 2006, 04:33 PM:name=Bavilo)--][div class=\'quotetop\']QUOTE(Bavilo @ Mar 24 2006, 04:33 PM) [snapback]358064[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hello,

I was thinking about adding a search field on my site. A field where i just enter some text, click search, and then a new page pops up with the google results of that query. What i need to know is how to append the following: site:http://mysite.com so it actually calls for "blah blah site:http://mysite.com" Can i do this using php?

Thanks
Mike
[/quote]


Ya gotta do some URL hacking

Instead of opening google.com, open up [a href=\"http://www.google.com/search?hl=en&q=my+search+term+site%3Amysite.com\" target=\"_blank\"]http://www.google.com/search?hl=en&q=mysea...te%3Amysite.com[/a]

where

[code]
http://www.google.com/search?hl=en&q=
[/code]
Is part of google's parameters and
[code]
my+search+term
[/code]
Is your search term
[code]
+site%3Amysite.com
[/code]
Specifies to search your domain at mysite.com

you can then use
[code]
header("Location: http://www.google.com/search?hl=en&q=my+search+term+site%3Amysite.com");
[/code]
to redirect the browser to your home rolled URL.

Share this post


Link to post
Share on other sites
Hi, sorry for the HUGE bump, but I'm having the same trouble. Call me a complete n00b, but I have no idea how to get this to work. I'm using Dreamweaver, and I'm trying to create a search function based on the same idea. Could someone please lay out exactly what I need to do? I'm clueless. Thanks!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.