Populating A Drop Down List With Php
I am trying to get a drop down list to populate vbia php. What I have a is a script that allows a airline/user to enter airfare and price for tickets. It dumps them into a database and then allows the user to view/delete/add.
I want the user to be able to edit the airfare. I have a drop down list that is set as a variable $ticket_from, $ticket_to. The list contains around 400 cities. When the user clicks 'edit' I have the price population but no the drop down list. How do you go about something like that? I have this right now: Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Populating Drop Down List With Selected Vaue
I have a drop down box and the "selected" value needs to be selected by a dynamic value that gets entered into the database, this is currently how im doing it: PHP Code: <?php                 if($modify_row[21] == "0") {                   print "<option value=" "></option>";                   print "<option value="1">Active</option>";                   print "<option value="0" selected>In-Active</option>";                 } elseif ($modify_row[21] == "1") {                   print "<option value=" "></option>";                   print "<option value="1" selected>Active</option>"; Its fairly straight forward, basically the option that is automatically selected needs to be the one coming from the database $modify_row[21].
View Replies !
Populating Drop Down
How do I do this drop down box ? Making an edit page. I have 2 tables groups id || categoryname program id || cateogry_id I need to populate the groups in it at same time show the selected choice from program. Not showing id but needs to show categoryname with of course the values being the id of groups.
View Replies !
Populating A Drop Down Menu
How would I go about populating a Drop Down menu from data in MySQL? If you can show me wither a URL to learn this, or if you feel like telling me here, that would be great.
View Replies !
Populating Drop Down And Table
I have a database with the following fields. Name | Company | Date values in each column could be repeated, or not. as in there could be several same names with the same company with different dates, or different names with same company. How do I populate a table with this info and have drop down boxes, so that I can narrow down the search? For example: Name | Company | Date 12 | 1 | 1929 13 | 1 | 1929 14 | 1 | 1929 12 | 2 | 1929 12 | 4 | 1929 13 | 1 | 1941 12 | 6 | 1929 So if in the drop down I select '12' under name, only those entries with 12 are shown, and then I can further sort it by selecting only '1' under Company. Hope I'm clear, I manage to complicate things when I post them.
View Replies !
Auto Populating A Drop Down Box
Basically I'm setting up a website which needs an populated drop down box made up from all fields in a specific column of a table in a mysql db.... Here's the code I've made up using various tutorials.... <?php $user = ""; $host = "" $password = "" $dbName = "" /* make connection to database */ mysql_connect($host, $user, $password) OR DIE( "Unable to connect to database"); mysql_select_db($dbName); //did you forget this line? $sql = "SELECT model FROM usedVehicles"; $query = mysql_query($sql) or die(mysql_error() . "<br>$sql"); //use the or die(...) part ONLY IN DEVELOPMENT ?> <form action="action" method="post"> <select name="option"> <?php while ($row = mysql_fetch_array($result)) { echo "<option value="" . $row['model'] . "">" . $row['model'] . "</option> "; } ?> </select> <input type="submit"> </form> I've left out the connection details for obvious reasons... When I upload and try to test this, jus a blank drop down appears... there are definately fields in the column as I have tried the query on phpMyAdmin.
View Replies !
Populating Drop Down Lists
Could anyone help me on populating database driven drop down menus. I am trying to populate a second drop down list based on the selection of the first drop down list. I have the first drop down list running. Not sure about getting the second now.
View Replies !
Populating Drop Down From A Query
I'm trying to populate a drop-down box from the results of a query. I end up with the first option coming through and then blanks in the rest. Something like this... <option value=Acevedo>Acevedo</option> <option value=></option> <option value=></option> <option value=></option> <option value=></option> .......
View Replies !
Self Populating Drop Down Menus
i am trying to do is the following: I have a MySQL database that (very simplified) has a schema like this 'Students(Name, id, Course)' I would like to have a form on a web site that has 2 linked drop down menus, one 'Please select id' and one 'Please select course'. When a user of the site selects there Id from the first drop down menu, i want the second drop down menu to populate itself with the courses held in the database for the given users Id. I would like the first drop down menu to be populated from the database with a query similar to 'SELECT id FROM students'.
View Replies !
Populating Drop Down From MySQL
I am trying to populate a drop down menu of MySQL data using PHP and I have hit a snag. I think its probably something simple that a freah pair of eyes could pick out right away that I am just not seeing... For some reason only the "firstname" part of the data is populating in the drop down and I can't figure out why. When I try to make changes to the echo lines to correct this, nothing shows up including the "firstname" data. Code:
View Replies !
Populating Drop Down Menu
I use the following code snippet to build a drop down menu with the results of a query. How can I set the initial value of this input based on the result of another query? What I am trying to do is update records in the data base. The field WkEndDate is pulled along with the rest of the record and the drop down menu is built from a table of valid WkEndDate values. Code:
View Replies !
Populating Drop Down Fields
I am trying to populate a drop down menu with a mysql database. I was hoping to have a selection of months in the dropdown menu, based on date fields in my database when a user then selects a month, they will be brought to a new page that will have only the records created in that month. But in my database, the date is stored in this format: 2006-05-12 00:00:00 if you need to see my code, here it is: <? //database connection $query = mysql_query("SELECT * FROM casinocredit"); // start to print out the form echo "<form action="cats.php" method="POST"><select name="clients"><option value="" "selected">Select A Client</option>"; // loop through the records while ($row = mysql_fetch_array($query)) { echo "<option value="{$row['ID']}">{$row['ddate']}</option>"; }.........
View Replies !
Populating A Drop Box With Results From Database
I have a MySQL database with a table (category) with two fields, catId (int) and category (char(50)). What I want to do is to get all category names in this database and place all of them into a dropdown box on a web page so that the user can choose from the list of available categories.
View Replies !
Populating A Drop Down Via A File Directory?
I just wrote this code: $dir = "/images/news"; print "<select name='file'>"; $dir = opendir($dir); while (false !== ($file = readdir($dir))){ if (in_array($file, array(".", ".."))) continue; print "<option value='$file'>$file</option>"; } print "</select>"; But for some reason it is not populating. It instead echoes an empty drop down menu. Can anyone suggest anything?
View Replies !
Populating A Drop Down From A MySQL Table
When they click submit, I want the name dropped from "invite" and added to a table "guests" with their answer if they are coming and how many. I know the SQL to make it happen, but I am pretty sketchy about the PHP. Code:
View Replies !
Auto Populating Multiple Drop Downs.
im trying to create two dropdowns, i need the first one to be the category and the second one to be the subcategory. The category drop down autopopulates with the correct info from the database. and uses the table "category", the value of each drop down is represented by the "cat" field in the table (cat is basically and integer id number) and "Category" is used as what the user actually sees in the drop down (category is the actual word of the category). Once the category is selected i would like to have the sub category auto populate with everything that has the same values as the selected category (cat) Here is a break down of how the tables work. Table 1 Name: "category" Fields for Table 1: "cat" (the id number), "category" ( the actual name of the category) Table 2 Name: "subcategory" Fields for Table 2: "cat" (corresponds with the cat id from table 1 to pull the correct data), "subc" (the basic id of the subcategory), "subcat" the actual name of the subcategory. so the way i see it, have a normal drop down populated by a php query. then on change, populate subcategory drop down where cat = cat and display sub category.
View Replies !
Populating The Drop Down And Pressing The Submit Button
1. The first is I have two drop down menus. The first is "year" and the second is "mfr". When a user selects a year from the drop down it then populates the second drop down, mfr, from the MySQL database. Theat is working fine. But the problem I am having is the "submit" button (which I have labeled as "browse"). When I click it. Nothing happens, no action tacks place. I have looked over the code and I can't figure it out. (See Code Box 1 Below). 2. Right now the "mfr" drop down is populated by the MySQL database and reads with a list like "Acr", "Alp", etc. These are abreviations. I need to set up an array to have them instead read the entire mfr name. Example: Instead of "Acr" it needs to be "Acura". Instead of "Alp" it needs to be "Alpine". I need these full names to appear in the drop down. I know I need to do something like this (See Code Box 2 Below) but I can't get my finger on it. Code:
View Replies !
Populating City,state,country Drop Down Menu
In the registration form I have city, state, country fields. I was wondering if there was a database available on the net which has the list of states in each of the countries. That way when a user selects a country I could automatically populate the state drop down menu ...
View Replies !
Drop Down Menu Select And Populating Data Fields
I have a PHP/MySQL Content Management System set up for the job I work at. It's basically a shift program that lets users pick up shifts, post shifts, etc. The data fields are tied to the shift ID which is selected from a dynamically populated drop down box. However, I cannot get the data fields to be updated when I select a new value and I cannot get the form to accept the new selected Shift ID. I have tried using JavaScript but cannot quite get it to work. Code:
View Replies !
Populating Multiple Drop Down Boxes From Mysql Table
Am having a problem with a dynamic, multiple drop down box query. If I run the code with only one select, it populates fine. If I run it with 2 selects then only the first drop down box populates - the second drop down box is empty. Am wondering if I need to put the query into an array and populate the boxes from there. Code:
View Replies !
Populating Dropdown List
I am wanting to know how to populate the <SELECT> dropdown menu with all existing values from the DB and also have the value associated with that id selected. This is an updating area of my admin. Any ideas? Here's the code so far. At the moment it only retrieves the value assigned to that id. PHP Code:
View Replies !
Populating A List Dynamicly
Is there an easy way to populate a list dynamicly? It stinks javascript here, but I don't know how to do it with that either. I have one list A that contains enteries with ID's as values. List B should then fill with information from a database according to wich ID is choosen in list A. Since alot of otherthings is entered on the page to I would like to nopt have to deal with sending all the data and loading the same page again. Is there a way in PHP to link to the same page and have all the filled textfields stay as they were? Or do I have to use post? I have the thought of loading all the data from the database and having it in an array or something and having a javascript picking and writing the choosen ones to the list. But that would be alot of excess data so getting it "live" from the db would be better.
View Replies !
Populating A List/menu From MySQL
is there a way to populate a list, or a menu form using php, and MySQL? Basically i have a list, and i am planing to import 2 variables, id, and name, bouth id and name are variables loaded from MySQL (yes there are multiple id's, and name's) Name would be the label displayed, and the value would be id. Thats what i need. After that i will make a submit button, witch will post the selected id to a different file. How can i achive this? Does anyone hae any samples maybe?
View Replies !
Php And Drop Down List
I am coding an email form on a site. A user enters their name and contact email and then selects from a drop down list to which particular email the message should be sent: User1, User2, User3. Then the user types out a message and hits submit. My problem is that I am unsure as to how to grab the selection in the drop down list and pull the selection and place it like this: "$selection@domain.com". Here is the php code:
View Replies !
Drop Down Box To A List Box
i have this drop down box that displays the relevant info from the table that its loading. But the drop down box isn't quite so wise to use if there hundreds of rows. So what i wanted to do was change it to a list box instead ... would any one know how to do that? Code:
View Replies !
Drop-down List
I populate a drop-down list like this: echo "<select>"; foreach ( $ip_list as $var ) { echo "<option>"; echo $var; echo "</option>"; } echo "</select>"; Is it possible to have the selection in the drop-down list default to a particular value? For example, let's say the complete list of values looks like this: 65.162.31.155 210.213.149.6 68.190.20.83 130.202.234.254 68.122.35.157 When the page is loaded, I want 68.190.20.83 to appear as the selected value in the drop-down list. Can this be done? Any suggestions or examples welcome.
View Replies !
A Drop Down List
im just starting out with PHP and im making a website that hosts some images. Its going great so far but I want to have a drop down that can show my albums. such as: Â Â Â Â Â <form name="form" id="form"> Â Â Â Â Â Â <select name="jumpMenu" class="dropdown" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)"> Â Â Â Â Â Â Â <option value="#" selected="selected">Browse</option> Â Â Â Â Â Â Â <option value="#">Ground - Concrete</option> Â Â Â Â Â Â Â <option value="#">Grass</option> Â Â Â Â Â Â Â <option value="#">Metal</option> Â Â Â Â Â Â Â <option value="#">Graffiti</option> Â Â Â Â Â Â </select> Â Â Â Â Â </form> I want the entrys for this to come from my images folder. For example if i have images/holiday then holiday will come up in the list. Is there anywhere I can get an example of this?
View Replies !
Drop Down List
PHP Code: <? Â Â Â Â Â Â Â Â Â $query = "SELECT `teacher_id`, `teacher_name` FROM teachers ORDER BY `teacher_name`"; Â Â Â Â Â Â Â Â Â if ($r = mysql_query ($query)) { // Run the query. Â Â Â Â // Retrieve and print every record. Â Â Â Â Â Â Â Â Â Â Â Â Â Â while ($row = mysql_fetch_array ($r)) { Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â echo "<select name="teacher">"; Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â echo "<option value="{$row['teacher_id']}">'".{$row['teacher_name']}."'</option>"; Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â echo "</select>"; Â Â Â Â Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â Â Â }.....
View Replies !
$row In A Drop Down List
I have a query. where I loop through courses, I get the id for each course, pass it to the next page then, I want to query the database again with it, how do I do this. <select name="course"> <?PHP $query = "SELECT * FROM courses ORDER BY course_name"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) {  echo "<option id='".$row['id']."' >";  echo $row['course_name'];  echo ' ['.$row['course_date'].'] ' ; echo ' £'; echo $row['course_price']; // echo the number  echo '</option>';  } ?>  </select> Get the ID then pass it. how do I use it again on another page and another query.
View Replies !
A Dynamic Drop Down List
I need to create a dynamic drop down list. By this i mean that the webpage html form = select style will recieve all the values as based on a query to a mysql database. I have no problems quering the data base with PHP, But i need to make some kind of for loop that will add a new value to the selct form for each result from the database. my thought process go like this. 1. call data base to guery. (no problem) 2. make variable variables that will be created according to the number of results (these variables must be created according to results of query, not a problem i think) 3. make a form like this <form action = ***** method = post> <select name = ******> <option value = "This is a query result"> This is a query result> //This is the part i need to using a for loop and variable variables </select></form> so my problem is part 3, cause is this all done in PHP, or if i had all these variables, can i do this in HTML? Can i make a for loop in PHP that would break into HTML during these parts?
View Replies !
2 Drop Down List Using MYSQL
I have a model table with the following fields: MODEL_ID, MAKE_ID, NAME. And a make table with the following fields: MAKE_ID, NAME. The first drop down list (make) to select a make of a car i.e. Chevrolet, Ford. When a make is selected, then all the model for that paticular make appear in the second drop down list.
View Replies !
PHP And MYSQL Drop Down List
I need a script to create a drop down list which has vehicle makes. The vehicle make list should feed a vehicle model list so when I select a make all the models for the make appear in the model list. I have a make table which has MAKE_ID, make NAME and a model table which has MODEL_ID, MAKE_ID and model NAME. I tried using a script using javascript array but wherever I have a query that pulls the NAME from the database there's always a carriage return after the NAME which messes up the javascript array. I'd rather do it all with PHP if possible. If not please give me one that works and I don't have to spend hours troubleshooting.
View Replies !
Very Simple Drop-down List...
Hi! I'm having a problem with a very simple drop-down list since the page comes out with no elements in the drop-down but giving no errors. This is the code: <form name="year_search_form" method="post" action="results.php"> <select name="select_year" id="select_year"> <? $query="SELECT * FROM table ORDER BY year"; $result = mysql_query($query) or die ("Error in query: $query. " ..mysql_error()); while ($line = mysql_fetch_array($result)) { print ("<OPTION value=".$line['year']."></OPTION>"); } ?> </select> </form>
View Replies !
Drop Down List From An Array
I want the array to contain a valid year of birth for anyone between the ages of 16 and 80. I'm pretty sure this code is correct.(though it might be a bit sloppy to all you pros) Code:
View Replies !
Drop Down List With Months
I am trying to create a drop down list that has December 2006 as the first option and then goes up month and years till the current month and year (September 2007).
View Replies !
Putting List Into Drop Down
I am working on a directory of businesses which has 8 main categories and each category has several sub-categories. Example: Dining is a Category with Pizza, Fast Food, Chinese, etc. I have the sub-categories brought up in just a list on the left side of the page and when the user clicks on a sub-category it takes them from client_list.php to client_filter.php only showing businesses in that sub-category of the main category. So only pizza places listed under dining. However, I want to change the list to a (form) select box and then have the user click on the sub-category they want and then it takes them to the client_filter.php page to list only those bussinesses in that sub-categorie. So after that long explanation how do I change my code to do that. Here is my current code:
View Replies !
Insert From An Drop-down List
i have a table in wich i've inserted city's name.then i have an registration form in wich i want to display an dropdown list with the cities from the table, and if one city is selected to be automaticly added in the second table. how can i do that?
View Replies !
Custom Drop Down List
I am trying to get categories from the database and show them in a drop down list showing root category then their sub category underneath. Code:
View Replies !
Folder List Drop-Down
I am developing a PHP/MySQL project and as part of my initial setup and configuration scripts, the users can select a skin for the application, and a variable value ($skin) is updated to set the current skin, this works ok on it's own, but currently the user must manually type the skin name in a free-text box. Ideally this needs to be a drop-down option box, and I would like this to be populated by listing the sub-folders within the '/skins' folder, so that it's always up to date. The folder structure looks like this: /skins /skins/skin1 /skins/skin2 /skins/skin3 How can I use PHP to generate a list of the current sub-directories in 'skins' and populate the drop-down list?
View Replies !
Drop Down List Of Months
I am trying to create a drop down list with 12 months as the contents. I need to be able to determine what the latest month is and then put the 11 months before into it (in the correct order). For example, it is September 2007 obviously at the moment, so that will need to be the last and latest month in the list. The other 11 will be in reverse order going back to August 2006.
View Replies !
Drop Down List Menu.
How do I make one item required on my "drop down" list menu? E.g., let's say that I want one state to be selected, how do I make this possible with PHP? My PHP skill is amature, but I do understand most.
View Replies !
Drop Down List Processing
I created a simple form in drop down list for USPS and FedEx. How do you process the drop down list?. If I select FedEx option, how do you retrieve it soI can use it in a query to find the Shipping Company store in my database. PHP Code: <?php    include ("header.php");    print "Select shipping choice;    ?> <form action = "confirm.php" method = "post">                          <table border = 0>                  <tr>       <td>Shipping choice </td>          <select name="Shipper">
View Replies !
Dynamic Drop Down Box List - Php
I have two dropdown boxes. Two boxes have values from two different tables. They dont have any common field to relate with. I would like to display the values based on selecting the first combo box value. If i select first combo box value, then automaticlly the second drop down box value should be changed. Code: ....
View Replies !
PHP To Display Drop Down List
I'd like to have 3 drop down lists connected. Division Department and Section Where the options of Department are dependent on what is selected in Division and the options of Section are dependent on what is selected in Department. So far, all the examples I've found have been using JavaScript. Can I do this in PHP as I have no knowledge of JavaScript at all.
View Replies !
Retaining Drop Down List Box Value
I currently have my drop down lists populated by a table from the sql database how can i retain the selected option once the form has been submitted. I know how to do this with textfields but cant figure out the dropdown lists because its being populated by a db. My code is as follows. $cat = "<option value=>all</option>"; $cat .= "<option value=$row[id] $catselected>$row[name]</option>"; echo "<tr> "; echo "<td class="classadd1"><div class="maininputleft">category</div></td> "; echo "<td class="classadd2"> "; echo "<select name="in[catid]" style="width:200px;" onchange="changecat(this.options[this.selectedIndex].value)">$cat</select>"; echo "</td></tr> ";
View Replies !
|