Advertisement
Guest User

Untitled

a guest
May 28th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.66 KB | None | 0 0
  1. <?php
  2. //SEARCH.PHP PAGE FOR SEARCHING DATABASE OF BLUEPRINTS.
  3. $db_name="evedump";         #This is the eve data dump database
  4. $db_user="root";            #This is your mysql username
  5. $db_pass="password";        #Mysql password for the user
  6. $db_host="localhost";       #your mysql host address
  7. $error = "Connection Problem, Check settings and retry.";
  8. mysql_connect($db_host,$db_user,$db_pass) or Die($error);
  9.  
  10. $search=$_POST['search'];
  11. $submit =$_POST['submit'];
  12.  
  13. #check for eve database and essential tables
  14. Mysql_select_db("$db_name") or die("Database may not exists or was typed incorrectly");
  15.    
  16.     //Explode search terms
  17.     $inital_search = explode(" ",$search);
  18.     foreach($inital_search as $search_term)
  19.     {
  20.     //constuct query
  21.     $x++;
  22.     if($x==1)
  23.         $construct .= "  typeName like '%$search_term%'";
  24.     else
  25.         $construct .= " or typeName like '%$search_term%'";
  26.     }
  27.  
  28. $construct = "Select typeName,blueprintTypeID from allbpos where $construct";
  29. $run = mysql_query($construct);
  30. $foundnum = mysql_num_rows($run);
  31. while($get[]=mysql_fetch_assoc($run)){
  32. }
  33.  
  34. if($submit == "submit")
  35. {
  36.        
  37.  
  38.  
  39. if($foundnum==0)
  40.         echo "<h1>No Results Found</h1><br />";
  41.     else
  42.     {
  43.         echo "$foundnum results found!<p>";
  44.         foreach($get as $returned)
  45.         {?>
  46.             <a href='testing.php?id=<?=$returned['blueprintTypeID']?>'><?=$returned['typeName']?></a><br />
  47.             <!-- TODO Paginate this search --><!--
  48.             //TODO Add back to search
  49.         --><?}
  50.    
  51.     }
  52. }
  53. Else
  54. {?>
  55.     <form method=\"POST\" action=\"search.php\" name=\"BPlookup\"><br>
  56.   <div style=\"text-align: center;\"><input
  57.  maxlength=\"255\" size=\"150\" tabindex=\"1\"
  58.  name=\"search\"><input name=\"submit\" value=\"submit\"
  59.  type=\"submit\"><br>
  60.   </div>
  61. <?}?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement