Guest User

Untitled

a guest
Aug 25th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <?php
  2.  
  3. /* Created by Hirsh Agarwal of H2 Micro (www.h2micro.com) */
  4.  
  5. //Call the function every time the search query is updated
  6. function search ($searchQuery){
  7.  
  8. //Fields
  9. $searchResult = array();
  10. //Define Server Variables
  11. $db = ""; //Set Database Name
  12. $host = ""; //Set Database
  13. $dbPassword = ""; //Set Database Password
  14. $dbUsername = ""; //Set Database Username
  15.  
  16. //Open mySQL Server Connection
  17. mysql_connect($host, $dbUsername, $dbPassword, $db);
  18. //Select Database
  19. mysql_select_db($db);
  20.  
  21. //Query the database
  22. $result = mysql_query("SELECT * FROM tablename WHERE searchVar='$searchQuery'") or die (mysql_error()); //Make sure to update tablename and searchVar
  23. while($row = mysql_fetch_array($result)){
  24. $currentResult = $row['searchVar']; //Update with the row that you want to extract data from
  25. array_push($searchResult, $currentResult); //Add to the list of results from the query
  26. }
  27.  
  28. return $searchResult;
  29.  
  30. ?>
Add Comment
Please, Sign In to add comment