Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Created by Hirsh Agarwal of H2 Micro (www.h2micro.com) */
- //Call the function every time the search query is updated
- function search ($searchQuery){
- //Fields
- $searchResult = array();
- //Define Server Variables
- $db = ""; //Set Database Name
- $host = ""; //Set Database
- $dbPassword = ""; //Set Database Password
- $dbUsername = ""; //Set Database Username
- //Open mySQL Server Connection
- mysql_connect($host, $dbUsername, $dbPassword, $db);
- //Select Database
- mysql_select_db($db);
- //Query the database
- $result = mysql_query("SELECT * FROM tablename WHERE searchVar='$searchQuery'") or die (mysql_error()); //Make sure to update tablename and searchVar
- while($row = mysql_fetch_array($result)){
- $currentResult = $row['searchVar']; //Update with the row that you want to extract data from
- array_push($searchResult, $currentResult); //Add to the list of results from the query
- }
- return $searchResult;
- ?>
Add Comment
Please, Sign In to add comment