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 Complete Forum Thread with Replies
Related Forum Messages:
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 !
Passing Multiple Variables From Dependent Drop Downs
I have a drop-down menu that lists 25 items (vips), when selecting one item (multiple= "no"), the page reloads and opens another dropdown menu with 20 items (Servers) (multiple= "no"). When the user selects a server from the 2nd drop down, the are asked to complete a final action (two radio buttons) either "on" or "off". Based on this final selection the user is taken to a new page and a script is run to turn onoff the server they selected. 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 Downs
trying to get dropdowns to appear and getting no where! I have a script with a config file that has a list of options. I have added a list of ages like so: $age[0]= 18; $age[1]= 19; $age[2]= 20; I now want to include these in a page in a drop down menu and have tried this code : $ageshow .= "<option>$age</option>"; echo "<tr bgcolor =$bg2>"; echo "<td class="classadd1"><div class="maininputleft">Age:</div></td>"; echo "<td class="classadd2"><select name="in[sfield]">"; echo "$ageshow</select> "; echo "</td>"; echo "</tr>"; this does not list the ages but just has array in the drop down. What am I doing wrong?
View Replies !
Dependent Drop Downs?
I have a drop down menu populated from a database. There are 3 other drop downs on the page that I want to populate from the database AFTER the user has made a selection in the first list. Can that be done? Are there any scripts for that anywhere?
View Replies !
PHP 4.3.4 Upgrade ... Need Help With Drop Downs
I upgraded from PHP 4.1.2 to 4.3.4 (Mac OS X 10.2.8), and then had to adjust all of my form scripts to retrieve the POST variables explicitly (because 4.3.4 requires this). I did this like the following: <input type=text name=myinputbox> <input type=submit name=submit value=submit> ------- $myinputbox = $_POST[''myinputbox]; $submit = $_POST['submit']; That works just fine, and the variable data is available for use elsewhere in the script. Radio buttons and textareas also work in this way. However, my problem is that <SELECT> drop down menus apparently DO NOT work in this way. This renders my form useless without this ability. If you can post a reply code for retrieving the <SELECT> POST variable to the following code, I would appreciate it. <SELECT name="MENU"> <option>option1</option> <option>option2</option> <option>option3</option> </SELECT> I assumed it would be this (but didn't work): $MENU = $_POST['MENU']; Hope I am clear with my explanation.
View Replies !
Two Different Drop Downs From MySQL
I have a admin area for a website, and on some part the admin can select options from two different drop down boxes. Now i thought that it would be better to use one Query for both dropdowns. How can i get them together? I now have something similair twice: <select name="series_id" class="dropdownbox" id="series_id"> <option value="0">- select -</option> <?php $db = mysql_connect("localhost", "name", "pass"); mysql_select_db("db_name"); $result = mysql_query("SELECT * FROM series ORDER BY name"); if ($data = mysql_fetch_array($result)){ do { $current_id = $data['series_id']; if($current_id == $id){$selected = "selected";}; echo "<option value="".$data['series_id']."" ".$selected.">".ucfirst($data['name'])."</option> "; } while ($data = mysql_fetch_array($result)); } else { echo ""; }; mysql_close($db);?> </select> I hope it's clear what i mean. I do not make connection twice, but the rest is similair except for the tablename of course.
View Replies !
Dynamic Associated Drop Downs
I wrote a function to pull country values from my MySQL database into my forms country drop down list. This works great. However, I want to also pull region/state data for my form's region drop down list whenever a country is selected/changed in the country form field. I know I can do this with javascript but I want to do it with PHP only. Can I do like a onclick command on the country field and have it resubmit the query that populated the region field? I think this is possibe but not sure how to do it.
View Replies !
Dynamic Drop-downs
I need to have a drop-down form element for selecting a year. It must start at a partcular year (hard-coded), like 2004 and go on to the current one. Eg. PHP Code: <option value=2006>2006 <option value=2005>2005 <option value=2004>2004 I suppose it should be a loop but I normally such at date functions in general.
View Replies !
Checkboxes And Drop Downs
I have a script which depending on certain conditions being met outputs some checkboxes and drop downs that look like this:  if($service1 == "true"){    echo "<p>The price for Service 1 is: Â£$service1price, type of rate: $service1type. Tick this box if you want to enquire on this service:<input type="checkbox" name="service1selected" value="true"</p>"; echo "<p>Please select the number of people requiring this service:";      $display ='<select size="1" name="service1count">';  foreach(array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10+') as $value)  {       $selected = (isset($_POST['service1count']) && $_POST['service1count'] == $value ? ' selected="selected"' : ''); $display .= "<option value='$value'$selected>$value</option> ";  } ..........
View Replies !
Arrays, Drop Downs & Includes ...
I am setting up a classifieds site using a script bought in. set about hacking a few bits & pieces that I did not like, the script has mainly text fields but I wanted drop downs. I copied the way countries were populated using an include file & replicated 10 times, i read somewhere that multiple includes in a script can slow things immensely is this so? The code:
View Replies !
Dynamic Drop Downs With Php And Java
I'm working on a project where I need the drop down menus to be dynamic almost identical. I found a java code that looks to do what I want it to do. But, being that I know very little about this, I'm not sure what goes where.
View Replies !
Calculate Values From Drop Downs
I've been trying to get this to work myself all day long before posting here. I want to create an order form which includes 2 drop down menus, StartLength and EndLength, the menu options for both being: 0-10 min 10-30 min 30-60 min The respective values for each option are: 25 50 100 (the user should not see these values.) The total cost will be displayed and will be the average of the two values. I've tried several different things, and nothing has really worked. Here is the code I have at the moment.. Code:
View Replies !
MYSQL/PHP Dynamic Drop Downs
I have a dropdown menu that is being populated by my database. Basicly I'm each record has a category that it's associated with. When my dropdown is populated it displays a category for every record. Code:
View Replies !
Autopopulating Drop Downs Change To Nothing
I have a form that autopopulates and allows user to make changes where necessary. In this form are some drop down menus (hardcoded on the page). All the selections (50 states for example) are there. If I select a state it will then post to the database. If I don't select a state and just leave it as the previously selected state (not change the selection already made by a user) it puts a blank in the database. Code:
View Replies !
Question Dynamic Drop-downs.
<? $username="masked"; $password="masked"; $database="masked"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "SELECT Race FROM tblRace"; $result=mysql_query($query); $query1 = "SELECT concat_Name FROM tblRunner"; $result1=mysql_query($query1); <form action= "race-result_handle.php" method="GET"> Runner's Name: <select name="Runner_Name"> if(mysql_num_rows($result1))
View Replies !
SELECT Statement - Using Two Or Three Of The Drop Downs
I have a page that when you first go into, it outputs many lines from a MySQL database. Not a problem so far. It has five columns in it. Each column is a hyperlink so the user can sort of one of those columns. Still not a problem. I have that working perfectly. But, here is my problem. At the top of the page, I have a form with three options. They are drop down lists so the user can filter the main list down. I don't have a problem if the user only selects one of the drop down lists. But, if they filter down the list by using two or three of the drop downs, I am not sure how I would do the select statement. Here is some additional information. Code:
View Replies !
Changing Recordset Data By Drop Downs
I am trying to write some reporting for my application. I have a table with customers, and a table with date ranges called period (start and end). I want to display a recordset for the customer selected from a dropdown list and the period selected from a second dropdown. so once the data is selected I want to be able to change the selected period for the same customer or change the customer for the same period. I have the mySQL queries working just fine, I have tested my reports where I can pass $_GET's to and it works. I just don't know how to put together the dropdowns from the other tables and the post to get it all working.
View Replies !
Related Dynamic Drop Downs Problem
I had posted the problem a couple of months ago, but didn't get my answer. Finally; I found a code to. retrieve data from database and populate it in two related listbpxes (drop downs). Now, I need to insert the selected data into another table in my database again. How can I do that? Is there any idea?
View Replies !
Show Selected Value For Drop-downs In Dynamic Menus
I frequently work with forms where menus are pulled from a database. When a user enters data in the form and then saves it, if it is retrieved later, the form shows the saved data, including the drop-down menus. The way I normally do this in php is to first retrieve the data for the saved from. Then I create the menus and within the loop of creating the menus I simply add the word "selected" into the results row which equals the saved option on the form. Code:
View Replies !
Displaying Text In Drop Downs With Accent Characters And Similar
I have a strange issue which occurs on a drop down list - for a country and related district. The district can contain unusual characters and accents. Here is an example of some districts for a particular country: $arr_regions["as"][5] = "Ta'u"; $arr_regions["as"][6] = "Tutuila"; When my form FIRST loads, and you select American Samoa, it correctly displays its regions. So array element 5 above shows as Ta'u (without the back slash). But very strangely when I reload the form, it displays the text in the district drop down as Ta'u . ie WITH the back slash. Here is the code for the country and district drop downs: ....
View Replies !
Auto Populating Form Fields
I know this isn't a PHP thing. But, I've been unsuccessfully looking for how to populate form fields with data found in other fields. For example, I would like to populate shipping information with the billing information - if they are the same. This would save the time from entering the same address twice. Does anyone know of a javascript site that is decent at these options?
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 !
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 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 !
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 !
Auto Drop Down Box
I am trying to create 2 drop down boxes, for example Country and state so when country is selected it will show in the second drop down box the correct list of states. I know how to do it with an if command in the second box but it requires a form to be submit but because it is already a form, how would I make a form inside a form work?
View Replies !
Create An Auto Drop Down Box
I need to create an auto drop down box. For example I already have a list of states that are pulled from the database. When the user selects a state, a drop down box below should populate with the cities from that state. (that's where I'm having trouble) This is a search form so the results have to reflect what city and state they chose. (along with some other criteria) I've searched all evening for instructions on how to do this and so far I've only seen javascript that you put directly in the code. If I have all 50 states along with their related cities that's an awful lot of code to put in the page. Isn't there a way to automatically pull the cities from the database to populate the box when the user clicks a state? I have no idea where to start to make that work.
View Replies !
Populating Multiple Rows
This is a very beginner's question. I have a mySQL database with 100 rows. I just created a new field (subjectID). All the rows in this new field will have the same data, the number "3". Would somebody please inform me on the command to insert this data in all the rows at the same time.
View Replies !
Auto-setting A Select Drop-down
I have 3 select menus for dates, I need to be able to auto set (on load) which number in the dropdown is selected, for example, if the date I pass to the page is this: 01/15/2007 I would use explode("/", $date) to get each number, I know for a fact that the format will always be (month)/(day)/(year), so no worries with that, but then how would I make it so that January is selected automatically, as is 15th, and the year 2007, in the drop-down menus?
View Replies !
Populating SELECT Multiple Form Field And Inserting Into Db
I have an update form where I'm trying to populate a SELECT multiple field with a list of 48 categories, from tbl work_cat. And show, as SELECTED, the one or many choices that the user had previously selected from the 48 categories which are stored in tbl cat_relations as $relation_cat. Then allow the user to update their selections and update the database. But I can't get my form to work. First problem, I can't get the SELECT field on the form to show the categories, and then I don't know where to go from there. Below are my form page and my processing page. Code:
View Replies !
Multiple Table Insert - Auto Increment Value
I have a table that when you add a new department it will add the name to the table and assign the row and id based on an auto_increment column. From there you need to get the value of the last insert id. SO what I did was use the msql_insert_is() function. and assigned it to a variable. I then used that variable in my next query because this vaule is a forigen key in another table. Here is my code it should be exectued if you where to post this page with the value of $department_id = "" then the section of script in question will execture. Essentially need it to grab this id number and then place it into 2 more insert statements that should execute immediately after the first insert statement. Then only insert id that I would need is the one produced in the first insert statement what an auto increment value is assigned to the same table as the department_name Code:
View Replies !
PEAR DB_DataObject Auto-generator Multiple Databases
I'm using the DB_DataObject script createTables.php to auto-generate the necessary database schema on two databases. Using the .ini approach (not the in-line PHP approach) to configure DB_DataObject in my script. Everything is by the book, but I'm having a big problem: Here's my main.ini file: [DB_DataObject] database_one = mysql://user:password@localhost/one database_two = mysql://user:password@localhost/one schema_location = /home/user/classes/dataobjects class_location = /home/user/classes/dataobjects require_prefix = /home/user/classes/dataobjects class_prefix = DataObject_ And here's my database connect file: <?php // separate classes for each database class DataObject_one extends DB_DataObject { var $_database = 'one' } class DataObject_two extends DB_DataObject { var $_database = 'two' } $config = parse_ini_file('/home/user/classes/main.ini', TRUE); foreach($config as $class=>$value) { $options = &PEAR::getStaticProperty($class,'options'); $options = $value; } $DB = DataObject_one::factory("tableName"); // etc... ?> The problem is that the auto-generator createTables.php copies everything into one directory, regardless of the number of databases you enter in your .ini file, which means, as is the case for me in this example, if you have two tables with the same name on different databases, it'll keep overwriting the same file, and the resulting class is the LAST one you enter in your .ini file. So my question is this: is there a way to specify different subdirectories for different databases in your initial configuration file? If not, is there no other solution than giving every table a unique name across an entire MySQL server if you don't want to do any coding?
View Replies !
Multiple Drop Down Search
i created two dropdown lists. One lists the months. And one lists the years. I want to be able to populate a sql query with the choices the user makes in the dropdown to display the correct choices. PHP Code:
View Replies !
|