sdotsen Posted April 12, 2007 Share Posted April 12, 2007 Came across the following tutorial. http://www.gadgetopia.com/autosuggest/ Works great and I got it to read from my mysql DB. However, if I have "John Brown" stored in the array, it works fine and shows up in the dropdown if you type the letter "J." However, if you type in B, it doesnt bring it up. Any way to do this or am I basically out of luck? The following is my SQL statement to pull the usernames. $sql = "select f_name, l_name from contacts"; $result = mysql_query($sql); $num_results = mysql_num_rows($result); $test_array = array(); while($myrow = mysql_fetch_array($result)) // grabs number of users to email from associated list { $haha = $myrow['f_name']; $haha2 = $myrow['l_name']; $haha3 = "$haha $haha2"; //array_push($test_array, $myrow['f_name']); array_push($test_array, $haha3); } So in the drop down it'll print out "John Brown." Maybe the sample code I found in the link I mentioned in the beginning is limited. I've tried other "auto suggest" scripts and they were either too hard to modify or it didnt do that great of a job. Quote Link to comment Share on other sites More sharing options...
btherl Posted April 12, 2007 Share Posted April 12, 2007 Do you want "John Brown" to show up when you press B? If so, that'll require modification of the javascript rather than your php. That's because it's the javascript that decides which strings to display when you press a letter. Quote Link to comment Share on other sites More sharing options...
sdotsen Posted April 13, 2007 Author Share Posted April 13, 2007 That's exactly what I want. If i'm searching for a person and I dont recall their first name but only know them by "Mr Brown" I would like "john brown" to show up. Just like if I type in "john" it would show it as well. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.