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 Complete Forum Thread with Replies
Related Forum Messages:
PHP And Drop-down Lists
I want a simple HTML drop-down list like this: <select name="select_1"> <option name="option_1" value="option_1" selected="true"> <option name="option_2" value="option_2" selected="false"> </select> to be able to automatically select a value according to a value in a table in the database. For example, if a MySQL table has a field named "field_1", and one of the rows has a value of "option_1" in that field, I want the list (using PHP of course) to automatically select the option name "option_1". How would I go about doing that?
View Replies !
Drop Down Lists
I have used Php to generate a drop down but becos the action of the form is it itself ($_SERVER) I need to echo the value upon submission. Becos this is php generated I'm having problems. This is what the current code looks like: [PHP] echo "<select name="branch"> <option value="$variable">$variable</option> </select>";
View Replies !
Dpendent Drop Down Lists
I'm making a system for outage reports, I have a field that refers to the outage type. I want when choosing from the list, for example, POP, all fields hat doesn't refer to POP issues to disappear. I made a demo with a software PHPrunner 4.1 and you can check it out. exapmle: I choose DNS so all feilds refer to POP and other issues should disappear.
View Replies !
Drop Down Lists And Textfields
I've found this is a great place to learn, so hopefully such can happen with the following: Basically, I'm trying to develop a world market for a text-based game wherein what is available is listed inside a drop-down list, followed by an input box where the user can enter the amount to purchase (up to the quantity amount available) and submit. Likewise, I've got a drop-down list populated via a MySQL query. Altogether, the page looks like this: My question is, how does one associate the input box with the drop-down list, assuming it's possible (which I would assume)? Currently, it displays correctly, however when one submits via the "Purcase Goods" button, nothing occurs. I'm not quite sure how to integrate everything coherently; my knowledge is limited in the area of PHP/HTML integration, so any explanation would be kindly appreciated. I know long streams of code are often unhelpful in pinpointing a problem (or problems), but in the interest of not excluding an element, here's the code of the file in question: ....
View Replies !
Dependent Drop Down Lists
I am building a data entry form in php to insert new records into a mysql database. There are two drop down lists - one for the Botanical name and one for the Common name of each possible plant. I need to make the two lists codependent so that if a user chooses by Botanical name, the correct matching Common name will automatically be selected, and vice versa.
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 !
Dynamic Drop Lists For Modify
Hello, I hope this is posted in the correct forum. This is a mix of php and javascript and what I am trying to do combines the two so I hope this is the best place for this post. I have 2 situations, one when adding an employee and the other is modifying the employee. I have a drop list the holds all of the companies that when you select a company, it changes the droplist of departments to show the available departments for the chosen company. So the dept droplist dynamically changes based off the company you choose. I have this working perfectly. THis is for adding an employee. My problem I have now is I need to modify the employee and when you first pull up the form with the employee info, it is populated from a mysql query. The droplist for companies is selected to the correct company, however, the droplist for depts is not because the javascript code I have is set to fill the dept list on an onchange event which on page load does not exist. If they select a different company, my code works fine but when they first hit the page, the dept list is blank because the onchange event has not been kicked off. I realize this is javascript but I am not sure where my changes need to be made. below is my code for the companies and depts only. I will leave out the other employee info becasue it is irrelavent. I will post what I have so far and hopefully you can guide me in the right direction Code: ....
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 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 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 !
Saving Selection In Drop-down Lists In PHP After Page Reload?
I can't find an answer to my quesiton anywhere. Given a drop-down list with USA states and other text fields I pass this information for further processing via PHP. If any of the required fields is empty, the PHP script would return an error and reload the form page asking to fill out those fields. All entered information is saved... except for the drop-down list selection. I tried to write a Javascript function which is echoed by PHP, but interpolation of PHP variables in the Javascript section gives a syntax error message in Javascript. The PHP script returns, e.g., an "AL" string for Alabama. Of course, I don't want to write PHP code for each option to make it selected.
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 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 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 !
Drop Down 2 Echo Seletion On Drop Down 1
I would like to put up a list/menu drop down so when you select something it echo's something in the second drop down. Example Drop menu 1 ----------------------- course 1 course 2 Drop menu 2 ------------------- If course 1 echo course 1 dates. If course 2 echo course 2 dates Does anyone have an example for me or what do I need to search for cause I don't quit know what it is called and thus I cannot find anything on Google.
View Replies !
Mailing Lists
I have searched in many places about how to set up a mailing list that is scalable yet no web sites seems to want to give out this info. I need to have this mailing list be effective even up to hundreds of thousands of users. Any advice/resources on how to set up this mailing list?
View Replies !
Email Lists
How would I go about making email lists? Someone who has something similar to what I want told me that they handle it with PHP. I'm not talking about a form where I can email an entire list, but rather an email GROUP, such that any time email went to URL from ANYONE that is a member of my site, it would come into domainname.com, and then sent back out to everyone in the "group". Any info would be helpful. Is this possible with php? What is the email process? Right now I'm not even on a domain name on my own server.
View Replies !
Ordering Lists
I have developed a script (with help) that tries to order events stored in my .txt file by date. The .txt file looks like this: 1st|Jan|Meeting at House| 15th|Feb|Meeting at your House etc The script orders the dates from lowest to highest but does not order dates before the 10th. Apparently 1st - 9th comes after 31st.. Code:
View Replies !
Dropdown Lists
I've been doing a site for a while now that has several drop down lists in a form. On one form there is the same drop down list repeated 3 times from the same table in a database but with different values. What would be the best way to repeat the code without repeating all of the code. Basically looking at an more economical way to do things. Would you do a while statement and loop through them or maybe a single array and call it when you need it. Any opions?
View Replies !
Maintaining Mailing Lists
I've few doubts; I'm asking two problem here. 1st, can we use PHP for maintaining mailing-lists. Say, we've 1000 users, need be e-mailed a subscription newsletter i.e. $message is same, loop through e-mail array in db. 2nd, Web site search. We maintain database after reading files using PHP and manipulate results from db. Question is, if PHP is a solution for these problems, also, when users' ( 1 ), keywords' ( 2 ) dbs grow big! There is also a limit of a PHP script execution. In 1st case, PHP has to parse, suppose 10k subscribers, and generate 10k e-mail for sendmail program. Is PHP feasible for such things. What else, is a better and professionally used solution. I don't know CGI? Perl?
View Replies !
Multiple Selection Lists?
i have a mutliple selection list on a form that goes like this <select name='name' multiple size=6>"; echo "<option value='one'>one"; echo "<option value='two'>two"; echo "<option value='three'>three"; etc it works fine. BUT how do u call it. For example say i selected option one and three. How do i call that on the next page so that ONE and THREE are stored.
View Replies !
Less-expensive Way To Set Up Defaults In Lists Etc?
I'm currently setting up default selections in <select> lists by passing an array of those defaults as keys ( 'valuefoo' => true ) as an argument to the function that sets up the list. Then, as I build each <option>, I call array_key_exists ( thisoptionvalue, arrayofdefaults ) to check whether to include the 'selected="selected"' string. So the code looks something like Routine ( array( 'valuefoo' => true, 'valuebar' => true ) ) ; ..... function Routine ( $defaultvals ) { for ( $i= etc. ) echo '<option....' . ( array_key_exists( 'curroptval', $defaultvals ) ? 'selected="selected"' : '' ) . etc ' ; } (I've elided a lot of syntax, but you get the idea) That seems slow and tedious. Does anyone know a cheaper way?
View Replies !
Quote's Invoices Lists...
I need someone to bounce some ideas off. This is what I'm trying to do, I want to be able to create a script that will spit out a quote based on the information filled in. The part I'm stuck on is. Entering all the items in. Ok, say I have a form, it starts off where you put in all the details (eg, who the quote is for address phone no etc.) Then there will be a list of items to go onto the quote. Now this is the part I'm stuck on. I'm thinking maybe something like an add new item button that opens a new window and then you enter in the details for each item. This then adds each item to the quote. Each item that is entered can be added directly to the database. So what I'm thinking maybe is a popup window that you fill in the details for each item, you hit submit, and then it goes back to the origional quote page, but now with the item added to the list. Maybe is there java script where you can open a new window and then refresh the parent window when the child is closed? this would then have the items listed.
View Replies !
Multiple Lists Selection
I am using a simple registration form that i made with the toolbox, but when I come to a multiple list to choose from (populated from the database) it doesn't work correctly. Of course, out of the multiple items selected only the last one gets inserted. From what I have read, the selection must be turned into an array then looped for this to work. Is this correct? Next how would I code this to work right. If you let me know which code to post, I will post it.
View Replies !
Multiple Selection Lists &
I have 2 multiple selection lists. I am using javascript so that users can select items from list 1 and move them to list 2. When the user submits the form I need my php to get the values he has/she has in list 2... I have done printf($_POST['list_2']) and it only shows one value, even when multiple are selected. I read that I need to change it's name to list_2[] but if I add the brackets to the name my javascript quits working.
View Replies !
Dynamic Dropdown Lists
I am recoding a greeting card website. I am using dropdowns as filters for items in a DB, so when the user picks "animals" from the "theme" dropdown, the returned cards all feature animals, and when the user picks "birthday" from the "message" option, the returned cards all feature birthday cards. However, there are some combinations that don't return any results, for example "get well" "floral" cards. Code:
View Replies !
Classes And Dropdown Lists
The class below works fine. The problem I have is there's a dropdown list in the middle of the loop. The dropdown list gets its data from another table in the database. Which goes through the same class. So I have a loop within a loop. What I'm trying to do is ....
View Replies !
Updating Lists On Page
The problem is that I am displaying all the rows of my table which have the value of the field 'approval' as 0. Now, there are to be 2 buttons next to each row with names "Approve" and "Disapprove". If you click on approve, then the value of 'approval' for that row becomes 1 and if you click on "Disapprove" , the value of 'approval' becomes -1. How to accomplish it ? as the list being viewed will be changing very often. Code:
View Replies !
Making Lists Of Words
Say I save into a field of a mySql database something like "two, three, four, five, six" all within one field, and then save each individual value into a spot in an array. So my array would go somewhat like a[0]=two a[1]=three and so on. I know how to do this in Java, but not in PHP. Similarly, is it legal so write $string = five; $string = $string + ',' + 'six'
View Replies !
Dynamic Unordered Lists
I have searched about for this one but havent quite found the low down i'm looking for but here goes. I'm trying to dynamically populate an unordered list from an SQL database which will have upto 5 or 6 sub-selections per top level list item so.. it would do something like this: Code:
View Replies !
Generating Combo Lists
Lets say I have an array: $fruitarr = array("apple", "banana", "orange", "lemon", "lime", "strawberry"); And I need to generate a list of smoothies over a period of 8 weeks. Each week only two of the fruits can be used together at a time. So for example, the choices for week 1 would be: Code:
View Replies !
|