neo777ph Posted March 2, 2007 Share Posted March 2, 2007 i had a used a drop list form field to show data coming from the database.. user should select one item from the droplist before he/she submits the page. example: <select name="employee"> <?php $strsql = "Select name,empid,vendorid,idemp from people where usercode = 'EMP' and local = '$local' order by name"; $result = mysql_query($strsql);// this query retrieves about 500 records $numrows = mysql_numrows($result); if ($numrows > 0) { $i = 0; while($i<$numrows){ $employee = mysql_result($result,$i,"name"); $employeeid = mysql_result($result,$i,"empid"); $vendorid = mysql_result($result,$i,"vendorid"); $idemp = mysql_result($result,$i,"idemp"); echo "<option value='$idemp'>$employee - $employeeid - $vendorid</option>"; $i++; } } ?> </select> However this form method is inefficient when i have to retrieve 500 records and list them on the droplist. Users of the system would look first on those 500 enlisted on the drop list..Even though i sorted it out..It still takes time for them to select the proper one on the droplist. My solution for the problem is to have a form field that acts like this.. if a user types on the input field "al": the field would shown all on the list that starts with "al" note: that the entry on the list camed from the database.. Hope I had delivered my point correctly..This implementation would faster our processing.. how can i do this algorithm? HELP -- the beatles asked for it..so am i.. => Quote Link to comment Share on other sites More sharing options...
btherl Posted March 2, 2007 Share Posted March 2, 2007 You can change the query like this: $strsql = "Select name,empid,vendorid,idemp from people where usercode = 'EMP' and local = '$local' and name ilike '$prefix%' order by name"; "ilike" does case-insensitive matching, "like" does case sensitive matching. $prefix is the variable for your new form field. 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.