Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $string = trim(mysql_real_escape_string($_POST['string']));
- $sql = "SELECT * FROM users WHERE firstName LIKE '%$string%' OR lastName LIKE '%$string%' ORDER BY firstName ASC";
- foreach($db->query($sql) as $row) {
- //usage of $row like: $name = $row['firstName']." ".$row['lastName'];
- }
- $sql = "SELECT * FROM users WHERE firstName like '%$string%' OR lastName like '%$string%' ORDER BY firstName ASC";
- foreach($db->query($sql) as $row) {
- $name = $row['firstName']. " ".$row['lastName'];//combing firstname with lastname
- //replacing æ,ø,å,Æ,Ø,Å with html friendly charcodes
- $remove = array("æ", "ø", "å", "Æ", "Ø", "Å");
- $with = array("æ", "ø", "å", "Æ", "Ø", "Å");
- $fname = str_replace($remove, $with, $name);
- //composing a answer to the user.
- $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>";
- }
Add Comment
Please, Sign In to add comment