home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / simpsrch.php3.txt < prev    next >
Encoding:
Text File  |  2002-05-06  |  1.6 KB  |  56 lines

  1. Simple Search on mysql database 
  2.  
  3. Simple Search on mysql database, and print no record when data not found 
  4.  
  5.  
  6. //search engine taken from my cheatzone 
  7. //http://idban.penguinpowered.com/cheat/ 
  8.  
  9. //// filename = search.php3 
  10.  
  11. <form method="post"  action="result.php3">  
  12. <select name="metode" size="1"> 
  13. <option value="row_name1">metode1</option> 
  14. <option value="row_name2">metode2</option> 
  15. </select> 
  16. <input type="text" name="search" size="25">  
  17. <input type="submit" value="Begin Searching!!">  
  18. </form> 
  19.  
  20.  
  21. //// filename = result.php3 
  22.  
  23. <? 
  24. $hostname =  "127.0.0.1";          // Usually localhost. 
  25. $username =  "username_for_mysql";      // If you have no username, leave this space empty. 
  26. $password =  "your_password";          // The same applies here. 
  27. $usertable =  "table_name";          // This is the table you made. 
  28. $dbName =  "database_name";          // This is the main database you connect to. 
  29.  
  30. MYSQL_CONNECT($hostname, $username, $password) OR DIE( "Unable to connect to database"); 
  31. @mysql_select_db(  "$dbName") or die(  "Unable to select database"); 
  32. ?> 
  33. <? 
  34. //error message (not found message)  
  35. $XX =  "No Record Found"; 
  36.  
  37. $query = mysql_query( "SELECT * FROM cheat WHERE $metode LIKE '%$search%' LIMIT 0, 30 "); 
  38. while ($row  =  mysql_fetch_array($query)) 
  39.    { 
  40.         $variable1=$row[ "row_name1"]; 
  41.         $variable2=$row[ "row_name2"]; 
  42.         $variable3=$row[ "row_name3"]; 
  43.  
  44.  
  45. print ( "this is for $variable1, and this print the variable2 end so on...");  
  46.    } 
  47.  
  48. //below this is the function for no record!! 
  49. if (!$variable1)  
  50. print ( "$XX"); 
  51. //end 
  52. ?> 
  53.  
  54.