SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    OK, one of the great things about storing all your stuff in databases is that it can be searched easily right ?

    So how the heck do i go about creating a search form for my site ? I really have no clue as to how to go about the SELECT statements etc.

    Please help ASAP :-)

    -James

  2. #2
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First of all, check out Kevin's tutorial. That will answer a lot of your questions. Then visit http://www.phpbuilder.com and read some there. That'll get all of your leftover questions.

    But here's how to use a SELECT statement to search.

    SELECT
    all relevant fields separated by commas, required to show results
    FROM
    the table where the content being searched is
    WHERE
    here's where you filter the results. Maybe WHERE TITLE LIKE '%$string_to_search%'
    ;

  3. #3
    SitePoint Evangelist
    Join Date
    May 2000
    Location
    Canada
    Posts
    533
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    as i was telling you in our chat :

    SELECT * FROM table,table2,table3 WHERE table.html_of_page LIKE '$string_to_search%' AND table2.html_whatever LIKE '%$string_to_search%';

    something in that form

    ------------------------------
    myONLYhost: when you want something MORE

  4. #4
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $result = mysql_query(
    "SELECT * FROM news,reviews,interviews,articles WHERE articles.body LIKE '%$term%' AND lps.reviewtext LIKE '%$term%' AND eps.reviewtext LIKE '%$term$' AND singles.reviewtext LIKE '%$term%' AND interviews.body LIKE '%$term%' ");
    if (!$result) {
    echo("<P>Error performing query: " .
    mysql_error() . "</P>");
    exit();
    }

    while ( $row = mysql_fetch_array($result) ) {


    WWWWwwhhhhhhhhhhatgoeshere

    }


    would this work ? and what would be pushed into the array ?


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
  •