If you want to search for a string that matches starting at the beginning, not in the middle, then just remove the first wildcard (%) from your query:
"SELECT title FROM autocomplete_demo WHERE title LIKE '" . $_POST ['search'] . "%'" Now it will match on france, frank, or fragile, but not 'the frame' or infrangible or any other string that doesn't begin with fra. Walter On Nov 11, 2008, at 3:10 AM, alohaaaron wrote: > > Hi, I'm trying to modify the demo here > http://wiseguysonly.com/demos/scriptaculous/ajax-autocompletion/ > autocomplete.php > which works great but I'd like to search character by character > instead of searching for a character within the string itself. > > For example, If I have these strings in a database coffee and frank > and I type fra I just want it to list frank, not coffee. > > The PHP script is below. Do I need to modify this an option for the > new Ajax.Autcomplete(); that will do this? > Thanks! > > $sql = "SELECT title FROM autocomplete_demo WHERE title LIKE '%" . > $_POST['search'] . "%'"; > $rs = mysql_query($sql); > > ?> > > <ul> > > <? while($data = mysql_fetch_assoc($rs)) { ?> > <li><? echo stripslashes($data['title']);?></li> > <? } ?> > > </ul> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---
