Im making this person search function build up of jquery(json) and php, the from the search bar are sent to the php document but it doesn't behave like i want it to.
I don't know if there's problem with the mysql server or the php code, but when i execute my search script it does not return values on (example):"e","s" or "r" but if i type in the whole name of a person, or just an "a" it returns all names with an "a" in it.
here is a little snip of my script:
$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'];
}
Update:
heres the whole script:
$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>";
}