Results 1 to 5 of 5

Thread: search keywords in all pages in my website

  1. #1
    Join Date
    Oct 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post search keywords in all pages in my website

    Hi,

    I'm trying to build a simple search engine to my PHP site. I finished building my MySQL database, which includes 15 tables. Now I don't know how can I search words trough my database..

    I want that when I search few words it will return me the name of tables which there exist in.

    How can I do it?

    Thanks in advance.

  2. #2
    Join Date
    Mar 2011
    Location
    N 11░ 19' 0.0012 E 142░ 15' 0
    Posts
    1,509
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    Building a search feature into a website, is not a simple task.
    If you're just beginning php, it's almost definitely to complex for you.

    If you're just trying to search for whatever words the enter in a database (different from making a search box), then all you have to do is (if you want to search for each word individually) separate the text the user inputs at the spaces ( use explode() ), then run a query against the mysql database. (Google mysql select).

    If you want to search different tables, you'll have to run multiple queries.

    If you need more information, please try and describe how you're tables look and what you're trying to achieve.

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    a simple search engine to my PHP site
    That's almost a contradiction. This is difficult, even for experienced PHP programmers. It's possible if you want to try it, but it's unclear from your post how experienced you are and how much time you want to dedicate to this.

    A good alternative is to use Google Custom Search embedded in your site. It's easy and it works pretty well.


    The first step to doing this is to make a copy of your site's content in a database (which it sounds like you've done) and make sure it's always updated. Additionally, it should be saved in a format so that it doesn't include things like HTML and other formatting-- just content words for searching-- but that should then be automatically updated as well. This takes a lot of work although it isn't necessarily difficult, just time consuming, if you already know how to work with databases.

    The second step is to build the search algorithm itself, which is the difficult task. It's easy enough to make a one-word search using MySQL's LIKE %term% syntax. But to make it do more than that including things like operators ("-term" meaning "pages without 'term'", for example) and quotes, and in general multiword searches will be harder.

    I built a wiki (like wikipedia, but of my own design) a while ago and I posted the algorithm here if you'd like to look at it. Here's that discussion:
    http://www.dynamicdrive.com/forums/s...588#post255588
    The last 2 posts contain the code. But if you read the entire discussion you might learn more about how it works if you want.



    By the way, when you say "keywords" there is another, simpler model: don't allow full-text searching. Instead use "tags" (or "keywords") on all pages and just search by those. A long time ago I designed something like that and it worked well except for needing to manually update the keywords when content changed. It was for a resources section on the site, though, so it didn't change too much (for each individual item, at least). It also isn't quite as effective because only keywords/tags are found rather than full text. That could potentially confuse users, but if you design the tags/keywords correctly it should work well. Or you can do it with a list of some sort rather than allowing users to type in any word they'd like.
    The same principle applies for something like a clothing store-- you don't need full text searching. Just a search form with select menus for size, color, brand, model, etc.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    47
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by djr33 View Post

    A good alternative is to use Google Custom Search embedded in your site. It's easy and it works pretty well.

    An easy option is this already mentioned by Daniel:
    http://www.google.com.au/cse/manage/create
    It's very simple to install if you don't want to make your own searching capability.
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

  5. #5
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    1,696
    Thanks
    82
    Thanked 90 Times in 88 Posts

    Default

    Taking the time to make your own certainly has some benefits. You have greater control over what content is searched and the results are pulled in real time. We would be happy to help you with the process of designing one if you decide to go that route. That thread that djr33 referenced should help you to get a good start. Some of it may be a bit complicated, so feel free to ask for more detailed explanations of whatever you are having trouble with.
    To choose the lesser of two evils is still to choose evil. My personal site

Similar Threads

  1. Website Search Facility
    By tony9339 in forum Looking for such a script or service
    Replies: 0
    Last Post: 01-27-2012, 01:25 PM
  2. add a search to my website
    By remp in forum PHP
    Replies: 4
    Last Post: 03-09-2011, 12:58 AM
  3. 500 Internal Eror on some pages of website.
    By chetanmadaan in forum Other
    Replies: 5
    Last Post: 11-11-2009, 02:54 AM
  4. Keywords for google search engine.
    By Ty Sovanmony in forum HTML
    Replies: 3
    Last Post: 06-28-2007, 10:52 AM
  5. Website Search Box
    By Ch3vr0n in forum JavaScript
    Replies: 7
    Last Post: 02-09-2005, 09:36 AM

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
  •