Search Engine

php Malaysia
  • 17 years ago

    Hi, im very new in PHP. What i want to asked is where i can find a script to do a simple search engine by using php connect to the mySQL. for example i have list of music in my database, and i want to search by Song title, Artis, or price. Thanks

  • 17 years ago

    Hi RedSouljaz,

    You could build your own small search engine for this, like so



    <form action="result.php" method="get">
    <input type="text" name="search"><br>
    <input type="radio" name="option" value="1" checked> All<br>
    <input type="radio" name="option" value="2"> Song<br>
    <input type="radio" name="option" value="3"> Artist<br>
    <input type="radio" name="option" value="4"> Price<br>
    <input type="submit" value="search">



    //database connection code here

    switch $GET["option"] {
     case 1:
       sql = "select * from mytable where song like '%".$
    GET["search"]."%' and artist like '%".$GET["search"]."%' and price like '%".$GET["search"]."%' ";
     case 2:
       sql = "select * from mytable where song like '%".$GET["search"]."%' ";
     case 3:
       sql = "select * from mytable where artist like '%".$
    GET["search"]."%' ";
     case 4:
       sql = "select * from mytable where price like '%".$GET["search"]."%' ";
       sql = "select * from mytable where song like '%".$
    GET["search"]."%' and artist like '%".$GET["search"]."%' and price like '%".$GET["search"]."%' ";

    // code to run query and show results on page....

    hope this helps

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Some people, when confronted with a problem, think "I know, I’ll use regular expressions." Now they have two problems.” - Jamie Zawinski