Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2010
    Posts
    1

    Unanswered: search script, witch functions ?

    Hello

    I would like to build mini search system.
    I have one column in DB,
    i choose correct rows by "against match" query,
    and i want to display result in short way.

    Example should tell what I mean:

    $searchString = "aaaa bbbb cccc";

    result:
    sdsdssdsd aaaa dsd sdsd sd aaaa bbbb dsdsd ... asas bbbb dsfe ...
    dsdsd bbbb cccc dsdsd ... asas bbbb dsfe ....

    It's like in google search, where desctription of site are show.

    I will be glad for working script to do it
    or just a helpful function, class etc.

    Peace <3

  2. #2
    Join Date
    Aug 2010
    Posts
    1
    PHP Code:
    <form name="search" method="post" action="<? echo $PHP_SELF; ?>">
    <table width="331" border="0">
    <tr>
    <td width="76">Keyword:</td>
    <td width="245">
    <input type="text" name="keyword">
    </font></td>
    </tr>
    </table>
    <br>
    <input type="submit" name="Submit" value="Search">
    </form>


    PHP Code:
    <?php
    mysql_connect("localhost","username", "password");
    mysql_select_db("database");

    if($Submit == "Search"){
    echo"Tėm kiếm <b>$keyword</b><br><br>";

    $result=mysql_query("SELECT * FROM `table` WHERE 1 AND `username` LIKE '$keyword%'");

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

    printf("%s<br>", $row["username"]);
    }
    /* Kết quả */
    mysql_free_result($result);
    }
    ?>

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •