Search Code

  Home arrow Search Code arrow Simple Search on mysql database
SEARCH CODE

Simple Search on mysql database
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 37
    2002-01-18

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    Simple Search on mysql database, and print no record when data not found
    drop down menu with more than 3 options

    By : idban

    <?
    //// filename = search.php3
    <form method="post" action="result.php3">
    <select name="metode" size="1">
    <option value="row_name1">metode1</option>
    <option value="row_name2">metode2</option>
    </select>
    <input type="text" name="search" size="25">
    <input type="submit" value="Begin Searching!!">
    </form>
    ?>

    //// filename = result.php3
    <?
    $hostname = "127.0.0.1"; // Usually localhost.
    $username = "username_for_mysql"; // If you have no username, leave this space empty.
    $password = "your_password"; // The same applies here.
    $usertable = "table_name"; // This is the table you made.
    $dbName = "database_name"; // This is the main database you connect to.
    MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database");
    @mysql_select_db( "$dbName") or die( "Unable to select database");
    ?>
    <?
    //error message (not found message)
    $XX = "No Record Found";
    $query = mysql_query("SELECT * FROM $usertable WHERE $metode LIKE '%$search%' LIMIT 0, 30 ");
    while ($row = mysql_fetch_array($query))
    {
    $variable1=$row["row_name1"];
    $variable2=$row["row_name2"];
    $variable3=$row["row_name3"];
    print ("this is for $variable1, and this print the variable2 end so on...");
    }

    //below this is the function for no record!!
    if (!$variable1)
    {
    print ("$XX");
    }
    //end
    ?>
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Search Code Articles
    More By Codewalkers

    blog comments powered by Disqus
    escort BursaBursa escortescort BursaBursa escortescort BursaAntalya escort bayan Antalya eskort Antalya eskort Antalya escort bayanlar Antalya bayan escort

    SEARCH CODE ARTICLES

    - PHP IP Blocking
    - Search engine with ranking feature
    - Ajax access to Google API
    - Table Searcher
    - Search_It
    - FTP SEARCH
    - Search and Replace class
    - Simple Search on mysql database
    - Search Your Database
    - search_v1.1
    - Database Searching Class

    Developer Shed Affiliates

     



    © 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap