Guest User

Untitled

a guest
Jan 19th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. $string = trim(mysql_real_escape_string($_POST['string']));
  2.  
  3. $sql = "SELECT * FROM users WHERE firstName LIKE '%$string%' OR lastName LIKE '%$string%' ORDER BY firstName ASC";
  4. foreach($db->query($sql) as $row) {
  5. //usage of $row like: $name = $row['firstName']." ".$row['lastName'];
  6. }
  7.  
  8. $sql = "SELECT * FROM users WHERE firstName like '%$string%' OR lastName like '%$string%' ORDER BY firstName ASC";
  9. foreach($db->query($sql) as $row) {
  10.  
  11. $name = $row['firstName']. " ".$row['lastName'];//combing firstname with lastname
  12. //replacing æ,ø,å,Æ,Ø,Å with html friendly charcodes
  13. $remove = array("æ", "ø", "å", "Æ", "Ø", "Å");
  14. $with = array("æ", "ø", "å", "Æ", "Ø", "Å");
  15. $fname = str_replace($remove, $with, $name);
  16.  
  17. //composing a answer to the user.
  18. $stringUser[] = "<li class='searchResultHit'><div class='searchResultLeft'><img src='".$row['picture']."'></div><div class='searchResultCenter'><span class='searchResultContent'><a href='user.php?id=".$row['id']."'>".$fname."</a></span></div></li>";
  19. }
Add Comment
Please, Sign In to add comment