Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. <?php
  2. if (!isset($_POST['submit'])) {
  3.   echo "Blank box.  retry";
  4. } else {
  5.   $tag = $_POST['submit'];
  6.  
  7.   $location="localhost";
  8.   $username="sj";
  9.   $password="tc6859LNf8phSMBR";
  10.   $database="sj_xbl";
  11.  
  12.   mysql_connect($location,$username,$password);
  13.   mysql_select_db($database) or die( "Unable to select database");
  14.   $qtag = mysql_real_escape_string($tag);
  15.  
  16.   $to_send = explode(" ", $qtag);
  17.   unset ($result);
  18.   foreach ($to_send as $send_item) {
  19.     $result[] = search($send_item);
  20.   }
  21.   foreach ($result as $result_item) {
  22.     foreach ($result_item as $result_item_item) {
  23.       $final[] = $result_item_item;
  24.     }
  25.   }
  26.   $result = $final;
  27.   // DEBUG: Show all matching results.
  28.   //print_r($result);
  29.  
  30.   // Output example:
  31.   foreach ($result as $result_item) {
  32.     echo "<a href=\"member.php?tag=".$result_item."\">".$result_item."</a>";
  33.   }
  34. }
  35.  
  36.  
  37.   function search($stag) {
  38.     $query="SELECT * FROM `members` WHERE `tag` LIKE '%$stag%'";
  39.     $result=mysql_query($query);
  40.     if(!$result) {
  41.       die(mysql_error());
  42.     }
  43.     unset ($tag);
  44.     while ($row = mysql_fetch_assoc($result)) {
  45.       $tag[] = $row['tag'];
  46.     }
  47.   return $tag;
  48.   }
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement