How to Create a Simple Search Function on my page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TGP
Forum Newbie
Posts: 6
Joined: Wed Jan 07, 2009 10:34 am

How to Create a Simple Search Function on my page

Post by TGP »

Hello, I'm looking to input a simple php script on all pages of my website that allows the user to search the entire site for a product.

I'm after something like this: Image

Any help greatly appreciated
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: How to Create a Simple Search Function on my page

Post by mattpointblank »

Is your content (products) stored in a database? If so, it should be fairly simple to write a script that takes user input (the search terms), cleans them up, and runs a SQL query against the database to find similar records.

If your content isn't in a database, this will be quite a bit harder. An easier option might be incorporating one of Google's free site search tools you can add.
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: How to Create a Simple Search Function on my page

Post by andyhoneycutt »

If you're looking for a very quick solution, you can always provide a google search feature on your website. If you're looking for a custom solution, you'll need to have a database back-end holding the data you wish to search. You'll need to write a script that will take the user's input and apply it to a sql query to help them find the results they wish to see.

-Andy

Edit: Wow, i'm slow.
TGP
Forum Newbie
Posts: 6
Joined: Wed Jan 07, 2009 10:34 am

Re: How to Create a Simple Search Function on my page

Post by TGP »

Oh ok thanks, erm no I don't have a database with the products on, could anyone give me an idea on how to do this and then code the search function to look through it like you mentioned.
Post Reply