SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Local site search

    Hi,

    I am a novice php programmer. How do make a php page search? What is indexing in page seach?

    Thanks.

  2. #2
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    Salem, OR
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    aryandelhi

    This is a v. broad question, in fact it could be read as a basic scope of work.

    If you would someone to do it for you try the Marketplace section?

    If I recall (although I do not have the book to hand), this title:

    http://www.amazon.com/Programming-Co...4081004&sr=8-2

    Has an example. You can get it for as little as $1.50 (used). It covers a lot of ground, and at least for me is still the ColdFusion MX bible.

    Hope that helps.

  3. #3
    SitePoint Member actionAction's Avatar
    Join Date
    Jun 2008
    Location
    STL
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by aryandelhi View Post
    Hi,

    I am a novice php programmer. How do make a php page search? What is indexing in page seach?

    Thanks.
    The easiest way to do this is with a database driven website. All of your page content would be coming from a database table, and you have a search form embedded on a page or a search page. Here is the most basic of examples:

    PHP Code:
    <form action="<?php echo($_SERVER['PHP-SELF']); ?>" method="POST">
    <input type="text" name="query" />
    <input type="submit" value="Search..." />
    </form>
    <?php
    if(isset($_POST['query'])
    {
       
    $q mysql_real_escape_string($_POST['query']);
       
    $sql mysql_query("SELECT * FROM content WHERE bodyText LIKE '%q%'");
       
    $result mysql_num_rows($sql);
       if(
    $result 0)
       {
           
    //Echo your page content or loop through the results echoing each with a link to the page
       
    }else{
           echo 
    "No results for "$q;
       }
    }
    ?>
    Again, this is basic, and probably nonfunctional as-is. It's just to show you the basic idea behind site searching. Otherwise, build a crawler for your site and have it index your site using a cron job (a lot more difficult).

  4. #4
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there any way to do this without database. I don't think it is complex task, as site search is very common. Sitepoint has also search feature.

    What is the right way to do this? I have several static pages. How to search those pages?

  5. #5
    SitePoint Member actionAction's Avatar
    Join Date
    Jun 2008
    Location
    STL
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is in fact a complex task. Just because something is common doesn't mean it is easy. Sitepoint's forum has a database based search feature, and it's site search feature is more than likely database driven. Why don't you just use Google site search? That wouldn't require you to do anything.

    google.com/coop/cse/

  6. #6
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot guys! While searching I found some tools like http://www.sphider.eu/. Does these tools work perfectly?

    How Do I use Indexing for page search?


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
  •