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
See Related Forum Messages: Follow the Links Below to View Complete Thread
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.
Auto-populating Multiple Boxes... Php And Pg_fetch_array Problem?
There is a nice tool using jquery/php to populate multiple select boxes out there, it must be a very stupid question but I?m trying to apply this tool to get data from postgreSQL, but I always get an empty [] value. It means that the...
Drop Down Lists Changing Depending On Other Drop Downs
I want to have a drop down system like this one. But without the radio buttons.
I want to have 3 drop downs but have no idea how to go about it. I assume I will need to activate some sort of Javascript on the onChange event of the option drop downs.
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?
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?
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.
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.
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.
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:
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.
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:
PHP + MYSQL, Populating Drop Down Box
I am looking to generate a dropdown box from MYSQL data:
db name = h2, table = Working, Column = Home.
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.
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.
Populating A Drop Down List With The Year
i'm trying to loop the years from 1960 - 2010 with the function get_year() below: PHP Code:
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.
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:
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 ...
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.
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?
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:
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?
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:
Multiple Drop Down Boxes
I want to create two multiple drop down boxes, the first will display all the company names, once this has been selected all the stock information for that company will appear in the second drop down boxes.
Multiple Selectiosn From Drop Down
I have a drop down box that I want people to be able to choose one or more of the options (multiple selection). How do I make mysql recognise this and add all entries into the table.
Multiple Dynamic Drop Down Population
I have a table with 3 pieces of data that I would like to use to dynamically populate 3 drop downs using javascript. The fields are state, orgname, office. If it's not already obvious, I'd like orgname drop down to change when a state is selected and I would like office drop down to change when an orgname is selected. I can do this with multiple tables but am having difficulty getting it to work when the data is in the same table. Below is the code to get state and orgname from separate tables(the code reflects one table and is broken in the below state). It's the best I can come up with and I can see why it doesn't work but I know there must be a way to pull all the pieces from a single table.
<code> $list=$_SESSION['list']; if(isset($list) and strlen($list) 0){ $quer=mysql_query("SELECT DISTINCT orgname,org_id FROM organization WHERE state=$list ORDER BY orgname"); }else{$quer=mysql_query("SELECT DISTINCT orgname FROM organization ORDER BY orgname"); } $quer2=mysql_query("SELECT DISTINCT state FROM organization ORDER BY state");
//first drop down echo "<select name='state' onchange="reload(this.form)"><option value=Ɔ'>Select one</option>"; while($state = mysql_fetch_array($quer2)) { if($state['org_id']==@$list){echo "<option selected value='$state[state]'>$state[state]</option>"."<BR>";} else{echo "<option value='$state[state]'>$state[state]</option>";} } echo "</select>";
//next drop down echo "<select name='org'><option value=''>Select one</option>"; while($org = mysql_fetch_array($quer)) { echo "<option value='$org[org_id]'>$org[orgname]</option>"; } echo "</select>"; </code>
Multiple Search With More Than 2 Drop Down Menu
I have problem with multiple search with more than 2 drop down menu. After submit from search.htm, in the results.php page i dont get results or error and i dont know where the problem is. look my code and tell me if you see something or error in sourcecode PHP Code:
Multiple Drop Down's For Search
I am looking at adding a search section to my site whereby visitors select from two drop down menu's and the desired page is displayed.
Similarly to many friend finder sites whereby you can select the age,sex and country of the person you are searching for.
Is there a way to do this without needing a database ?
Multiple Drop Down List Problem And MySQL
I am trying to populate around 30 drop down lists via a single query to a mySQL database. The problem is how to make sure that each drop down list only display it's relevant data. for example the table is as follows:
Filtering Selection In Multiple Drop Down Boxes
I want to allow a user to conduct a search on a database using multiple drop down boxes. On the first page they will have a drop box filled with records from field A. Once they select which one they want, a second drop down box will then appear with records from field B which are present for field A (a filter).
What I want though is that the first dwon down box still appears on the second page, but shows the record that the user selected. What is happening now is that when the second page comes up, the first box shows the default selection rather than the selection that the user chose. My code for the drop down boxes is: PHP Code:
Populating A Select Box
What I want to do for members of my website is to allow them to click a button that will add their name to a list that populates a select box. I can do this on my own, but I was curious if I have to use a database in order for this to be possible.
Populating Two Combo Boxes
I have one combo box (Category) which is populated by a MySQL table using php. I am trying to use the onchange javascript to submit the value selected so that I can populate the other combo box (sub-category) based on what was previously choosen. So can anybody give me a clue on how to submit the first boxes value so that the second can see what was selected (javascript function).
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:
Dymanic Populating Checkboxes
i like to retrieve a value from DB, accordingly i like to display the checkbox, either checked or not.
Now im able to retrieve the value from DB, i can show even show the checkbox, but i cant make it checked????
the Code i used to display as follows,
#Require the database class require_once('../dbinfoinc.php');
#Get an array containing the resulting record $query = "SELECT * FROM event"; $result = mysql_query($query);
$num=mysql_numrows($result); mysql_close();
$i=0; while ($i < $num) { if(($i % 2) == 0) { $c = '"TableDetail"' } else { $c = '"TableDetail2"' }
$event_id=mysql_result($result,$i,"event_id");
$event_name=mysql_result($result,$i,"event_name");
$event_publish=mysql_result($result,$i,"publish"); // if(($event_publish) == 0) { $event_publish = 'No' } // else { $event_publish = 'YES' } $take_action = 'Delete' echo "<tr> <td Class='navText' align='center' class=$c>$event_id</td> <td class='navText' class=$c>$event_name</td> <td class='navText' align='center' class=$c><input type='checkbox' name='publish' if($event_publish==1){'CHECKED'}?></td> <td class='navText' align='center' class=$c><a href='delete_event.php?event_id=$event_id'>$take_action</a></td></tr>";
$i++; } ?>
Re-populating A Form If Errors
I am learning php. I have created a simple Web page with a form. After receing the POST request, I do some error checking. In case of errors, I would like to re-post the page, but with the current values for each field.
I have organized my files like this: 1) Webpage with the form (all in html, form action points to a php file) 2) php file that receives the request.
Populating Form Text Box.
I have a PHP form for entering data on-line into a mySQL table.. Because of the intended search facility, I require one field in the form to be completed with exact and precise item names and spelling. In testing, I had achieved this with look-up tables. Ideally I would like the selected item from one of five drop-down lists to autopopulate the form text field when selected. Alternatively at least the option of copy and paste. Copy and paste - for some reason will not work. Autofill worked fine on a test form with no database connection and in standard HTML and javascript, however, once the PHP is added to the page neither method works. Could anyone please point me in the direction of how to get the autofill to work?
Populating A Select Box From A Database
I have a subscription database that allows you to edit a subscribers data. For example, you enter a search term like "Bob" and it returns a list of everyone named Bob. You click the one you want and it goes to a subscriber detail page, where all of his data is populated to a form. You can directly edit this form and click save to overwrite it.
The only issue is the select boxes (drop downs) - say I have four options in the drop down box, red, blue, green and black. On my details page for bob I end up with five, I have those four PLUS whatever was saved for his color, so it shows up twice. If Bob is green, my select box looks like:
Green Red Blue Green Black
How can I make it so that Green only shows up once?
Populating An Auto_increament Attribute
I have just designed a BD. there are companies with auto increament which are integer. When I try to populate it after i tool value from another form and try to insert it into a table i recieve an error! I don't ask the companyID value from user as it is auto increament. Don't tell me to put NULL for that entry as it didn't work as well! Code:
Populating Table Information
I am trying to dynamically generate bgcolors with to help populate some information for a site. Here is the code:
Populating Fresh Data
Im building a live web chat using php, mysql, javascript, ajax I am fine with sending and retreiving data in real time using ajax as the transfer protocol However, my problem, which is becoming a nightmare, is how to I display it !! Lets say the below is the chat screen,
<div id="messages"> Jamie - Hello Peter = Hi Jamie = Nice Day Peter = I know </div>
Lets say Jamie's next message is "What are you doing today". I can send that off to the database no problem and I can get peters live chat to pull that message in, however, how do I get it to display underneath Peter = I know
As a practice I was using
document.getelementbyid('messages').innerHTML = document.getelementbyid('messages').innerHTML + "<BR>What are you doing today"
That works, but, lets just say the chat gets to 1000 lines, for each new message those 1000 lines have to be pulled out via javascript, a new line written to it and then printed back in the div
Im not sure but I'd take a good guess at this not being optimal and will cause CPU load on the users machine
What is the best way to do this! Chat messages are deleted after 1 minute, but that doesnt matter because by then they have already been sent the the users chat. Just incase you are thinking of completely repopulating there chat with every message they have sent since the chat started..
Reading Directories, Populating Select Box
Can anybody tell me how to read through a directory, get the file names and populate a select box(pulldown menu) with these names? I know how to loop through a directory using something like this:
while ($files = readdir($handle)) {
$ext=substr($file,-4);
if ($files != "." && $files != ".." && $ext == ".php") {
do some wild and crazy stuff here;
}
}
It's the populating the select box (pulldown menu) while doing this that I need the help on.
Populating Form Item From SQL Enum Set Rev#2
$sql = "SHOW COLUMNS FROM table LIKE 'subject' "; $qry = mysql_query($sql) or die("Query not valid: " . mysql_error()); $res = mysql_fetch_object($qry); // This returns a row with a field 'Type' containing 'enum(...)'
$res->Type = str_replace('enum('', '', $res->Type); $res->Type = str_replace('')', '', $res->Type); //now the string is something like this: one','two','three
$temp = explode('','',$res->Type); //temp is an array with as much elements as the enum
while ($temp) print array_pop($temp);
This way is much more easier using the elements since they are elements of an array. Cleaver isn't it?
Populating Array With Mysql Results
I'm returning a result set of one field in a table, and want to populate an array with the results. I can't for the life of me figure out a simple way to do this without using mysql_fetch_array() to cycle through the results, append that to a var, then explode that into a var and pass that. PHP Code:
Populating A Form Wth Database Info
I've coded a piece of code which populates a form with data read from the database:
$connection=mysql_connec ("localhost", "f2821842", "f2821842"); $result=mysql_select_db("QUERIES"); $query=mysql_query("Select * from Emp_Details where emp_num = '$employnum'"); while($row=mysql_fetch_array($query)) {$empname=$row['emp_name'];}
<form name="webregform" action="webadmin2.php" method="post"> <input name="requiredname" type="text" size="30" value="<?php echo "$empname"; ?>"> </form>
When I echo the $requiredname, I get spaces and no data, and I know that $empname is not a space-it does read a value in a database. 1. How can I get $requiredname to print a value?
Populating Dynamically Generated TextFields
If one assigns something to the value iattribute off an input /text field, that value will be displayed when the form is loaded. My problem is, when building a form dynamically, the only way I can get the text to show is by doing the above, however, as this is an update form, when the form POSTS to processUpdate.php, both the data entered by the user AND the data in the value attribute are inserted/updated.
So, how does one dynamically build a form where the data is displayed in the text fields but value atttribute is not set. PHP Code:
Populating Form Fields With Variables
The script itself works fine: mail gets sent. If there are any missing fields the form displays again with a list of the missing fields, but I can't get the form fields of the reloaded form to be populated with teh existing values. PHP Code:
Populating DHTML Menu From MySQL
I have a client that would like to have drop down menus added to a nav bar that is generated from MySQL. Is it possible to have a dynamically driven DHTML menu from MySQL?
Populating Arrays From MySQL Query
I have the following code: http://pastebin.com/746601
The field 'material' in 'is_material' contains multiple values for each record in 'is_details'. Because of this I have used 'is_material_lookup' as a reference lookup table containing the 'style_code' and 'material_code' which refer to their full details in the respective tables.
Currently I have got the script outputting all the details and one material then in the next block of data, repeating the details with a different material. What I would like to achieve is having 1 block of data with a list of all materials in that, instead of the repeat, but sadly I can't know exactly how to do it.
Populating Dropdown With Mysql Entries
I would like to create a combobox in Flash which is populated with mysql data and programmed with php. For example: There are 3 entries in database .ie. apple, bannana, peach. Now these I want in combobox in Flash MX/flash5.
|