Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. <form action="index.php" method="GET">
  2. <input type="hidden" name="url" value="search" />
  3. <input type="text" name="query" class="text" placeholder="Søk etter prosjekter.." style="height:12px;"/>
  4. <input type="submit" value="" class="search-button" />
  5. </form>
  6.  
  7. <?php
  8.  
  9. $varr = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($url));
  10. $varr = html_entity_decode($url,null,'UTF-8');
  11.  
  12. $query = $_GET['query'];
  13. echo utf8_decode(urldecode( $query));
  14. $min_length = 2;
  15.  
  16. if(strlen($query) >= $min_length){
  17.  
  18. $query = htmlspecialchars($query);
  19.  
  20. $query = mysql_real_escape_string($query);
  21.  
  22.  
  23. $raw_results = mysql_query("SELECT *, account_created FROM users
  24. WHERE (`username` LIKE '%".$query."%') OR (`motto` LIKE '%".$query."%')ORDER BY account_created DESC") or die(mysql_error());
  25. $num_rows = mysql_num_rows($raw_results);
  26.  
  27. if(mysql_num_rows($raw_results) > 0){
  28.  
  29. while($results = mysql_fetch_array($raw_results)){
  30. $timestamp=$results['account_created'];
  31. echo '
  32. <a href="http://prosjektdatabasen.com/prosjekt/'.$results['username'].'"><div class="searchbg">
  33. <text style="float:right; font-size:12px; color:#2e7297;">' . gmdate("d.m.y", $timestamp) . '
  34. </text>
  35. <text style="font-size:17px; color:#494747; font-weight:bold; line-height:140%;">'.$results['username'].'</text><br />
  36.  
  37. <text style="color:#5e5d5d; line-height:130%;">' . wordwrap(substr($results['motto'], 0,120), 58 ,"\n", TRUE) . '...</text></div></a>
  38.  
  39.  
  40. ';
  41.  
  42. }
  43.  
  44. }
  45. else{ // if there is no matching rows do following
  46. echo '<text style="font-size:13px;">Fant ingen prosjekter med søket: <strong>'. $_GET['query'] .'</strong></text>';
  47. }
  48.  
  49. }
  50. else{ // if query length is less than minimum
  51. echo '<br /><text style="font-size:13px; color:red;">Søket må inneholde minst ' . $min_length . ' bokstaver.</text>';
  52. }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement