Q:

PHP - do IF checks on certain chars in a string to compare with from data in SQL db

I'm working on a suggestions tool: When the user types a char into a text field, the char gets sent off to a script (using AJAX) and is checked on in a SQL DB. If any entries in the DB match the users input, they get returned. 
But I'm stuck on actually going through the users input string;
I need to check all characters one-by-one with each row in the DB.
So i was thinking:
1.) get the char length of the string and put it into $string_count
2.) define $count=0;
3.) do a while loop and make it stop when $count reaches over or equal to $string_count.
4.) inside that while loop: do another while loop and use condition: $det=mysql_fetch_array()
5.) then i could get the data (name) from row 1, and do a check to see if its first char matches the users input first char (which i don't know how to do). 
6.)If it contains the correct char in the correct position, add the ID to a string with a comma after ($possible.=$det['id'].",";)
7.) Add one to $count ($count++;) in the parent while loop.
7.) that loop will go on, on every row, but obviously changing char each time, until there are no more chars to check...
I just wrote all that up from the top of my head, and now I'm lost. I think its completely wrong and there is a much easier way to do it? but can you guys just tell me if im on the right track? 
I need to know how to do a check on a certain char in a string. So for example:
$my_str="my name is nav nav";

now i want to get the forth char in that string (which is "n").
any suggestions?
Thanks guys.

A:

$my_str="my name is nav nav";

$charAt= $my_str{3};

echo $charAt;

//outputs n (strings are 0 indexed)

EDIT:  Also wait until the user has input at least three characters and just do a database query using LIKE everytime:
SELECT * FROM example WHERE age LIKE '$userinput%' 

http://www.htmlite.com/mysql011.php
(optimizing this is another story)

