prcollin Posted July 21, 2008 Share Posted July 21, 2008 I have an option on a form that is a drop down, I want it to auto populate with the current clients in the database. So basically everytime the form is called i want it to read my database and let me choose from any current client in the database on a name basis. I know how to make a list and drop down menu i dotn know how to auto populate it with the current names in a cllumn of my db though. Any help? Quote Link to comment Share on other sites More sharing options...
peranha Posted July 21, 2008 Share Posted July 21, 2008 <?php //this code is bringing in the values for dropdown number 1. $query="SELECT * FROM CHANGETOTABLE"; /* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */ $result = mysql_query ($query); echo "<option><select name=\"CHANGETOTABLE\" value='1'>CHANGEcity</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=\"$nt[VALUEOFOPTION]\">$nt[DISPLAYOFOPTION]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> Change a few things in that code and it will select the info from the database. Quote Link to comment Share on other sites More sharing options...
prcollin Posted July 21, 2008 Author Share Posted July 21, 2008 ok i will try this out and let you know how it goes 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.