Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Populating Drop Down Boxes From Database


I have two drop down boxes, the first one i am able to fill from my database using the following code. Code:




View Complete Forum Thread with Replies

Related Forum Messages:
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 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 !
Get The Values Chosen In The Drop Down Boxes To Correspond To Specifc Fields In A Database?
The purpose of this application: I need 2 combo boxes, one with months, and one with years. When the user chooses both a month and a year, a page is displayed with certain numbers that are retrieved from a database. Those numbers correspond to the specific month and year. For example, January 1998 produce "12", but February 2001 might display "73".

So I guess I'm asking 2 questions. The first is just a general outline of how someone might go about doing this (to see if i'm on the right track in my thinking). The second, and more important question is for someone to please explain to me how do I get the values chosen in the drop down boxes to correspond to specifc fields in a database?

View Replies !
Form Validation To Autofill The Previous Drop Boxes And Check Boxes
I have a form and when the form is submitted it is validated and processed. If validation is failed it returns the form on an error page and lists what was required that was not entered. It also auto-fills the previous submissions back in but I cannot get it to change drop-boxes or chec boxes.

View Replies !
How To Create The Form Boxes And Drop Down Boxes
Im going to create a php form that allows someone to signup to my web hosting site, once they have filled in all the relevant parts and the have selected the hosting package they want and hit the submit button.

i want the form to take them to a correct webpage that will allow them to pay for the package that they have selected on the form. I know how to create the form boxes and drop down boxes but i dont know the correct coding to pick up package variableon the last drop down box .

View Replies !
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).

View Replies !
Populating Select Boxes
I'm creating a data entry system using php/mysql that includes the standard add/update/delete forms in PHP with a MySQL backend.

On the update pages I'm trying to fill the select boxes (that come from other tables) with the values in those other tables, yet defaulting the selection in each of those select boxes to the value currently stored in the main table which is being updated.

For example, the main table is called 'dates' and a related table is called 'department'. So one of the select boxes should have all the various departments listed in the select box but the currently selected value should be whatever is in the department field in the 'dates' table for the record the user is trying to update. Code:

View Replies !
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...

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 !
PHP + MYSQL, Populating Drop Down Box
I am looking to generate a dropdown box from MYSQL data:

db name = h2, table = Working, Column = Home.

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 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 Down List With The Year
i'm trying to loop the years from 1960 - 2010 with the function get_year() below:
PHP Code:

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 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 !
Drop Down Boxes
This Select statement does not have any of the drop down box variables in the statement.
Code:

$query = "SELECT * FROM `View2_Concord` WHERE `Topic` LIKE '$SeeAlso%'
AND `Source` IN ('NV', 'TR', 'BT')
ORDER BY `Lnum` ASC";

Currently, the user selects the source field values of NV, TR, and/or BT by checking checkboxes on the html form below. I have added a new drop down box with text search related values. This is the form on the html page. Code:

<div align="center">
<center>
<table border="2" cellpadding="2" width="685">
<tr>
<td width="671">
<form method="Get" action="PostNewABC_Concord.php">
<p><b><font face="Arial" size="2">&nbsp; Tens <input type="checkbox" name="TR" value="ON">&nbsp;&nbsp;&nbsp;.....

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 !
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.

View Replies !
Form Drop Down Boxes
I have a bunch of products i want to add to a database, i have a form to submit the products to the database.

What i need to crack is to have a drop down box for category 1 (beer or wine) and then automatically populate the drop down box for category 2 depending on the first selection

if cat1 = beer then cat2 options = Lager, Malt, Stout.
if cat2 = Stout then cat3 = Guiness, london, Old boot.
if cat3 = Guiness then cat4 = Bottle, Can.

I have four sub categories so need this to work on the fly before adding all info to the database ...

View Replies !
Drop Down Answer Boxes
how to insert drop down answer boxes (like the oes you get in questionnaires) into my cong, i can't seem to get the coding right or make anything appear in the box.

View Replies !
Country Drop Down Boxes
On one of my pages I have a form with a country dropdown box, with every country in the world, so obviously it is quite big. if there is an easy to have the particular country that the user selected re-selected, if the user is returned back to the form based on an error on the rest of the form.

For example, if they have accidently submitted a blank field somewhere on the rest of the form and they are returned to the same form to correct the problem, I would like the country dropdown box to have what they previously selected, re-selected. Is there some way to do this with the country dropdown box without about 250 'if' statements?

View Replies !
Dynamic Drop Down Boxes
I am trying to figure out how to simulate the onChange() function from JavaScript with PHP.

What I am wanting to accomplish is to generate a second drop down select menu based upon the option selected in a first select menu.

I know this can be done using $_POST or through data stored in my mySQL database. What I am looking for is a way to generate DROP DOWN 2 on-the-fly when the selection in DROP DOWN 1 is changed (like with the onChange() function available through JavaScript).

View Replies !
DB Fields And Drop Down Boxes
What I'm Trying To Do:

Create two auto-populated drop-down boxes based on the contents of the CATEGORY and COOKINGMETHOD fields. These drop-down boxes will appear on a data entry webpage which submits its contents to the database.

3 Ways TO Achieve This (that I can think of):

1.) Break out CATEGORY and COOKINGMETHOD into their own tables then place their foreign key into RECIPE. This would allow the contents of each drop-down box to have the most accurate list of categories. It would also narrow down the possibility of a user misspelling a CATEGORY or COOKINGMETHOD, since an administrator would be in charge of adding a new CATEGORY or COOKINGMETHOD to the database.

In the current design (see attached image), if a recipe is deleted, its CATEGORY and COOKINGMETHOD are also deleted. Therefore, if Grilled Eggplant was the only desert in our recipe database, then when a user tries to enter a new desert recipe on the data entry webpage, the drop-down box will not have a desert option listed since it was deleted when Grilled Eggplant was deleted.
Database performance should be considered if going this route. Is it worth breaking these two fields out into their own tables just to satisfy the layout of the data entry page? What if there were more auto-populated drop-down boxes we wanted to place on the data entry webpage that were based on the contents of other fields? This could result in many small tables.

2.) Use the current design and auto-populate the drop-down boxes based on the values in CATEGORY and COOKINGMETHOD. Although the easiest method, it can lead to the same problem discussed in the later part of #1 (see above). This method would require an input box (so that users could create a new category if one is not listed in the drop-down box) and a drop-down box (so users could select a category if it is already listed in the drop-down box) on the data entry webpage. The chances of misspelling increase, two boxes are required instead of one, and the drop-down boxes might not always contain a category or cookingmethod for the recipe the user wants to enter.

3.) Auto-populate the drop-down boxes based on hard-coded values in the code. This would mean having to edit the code each time a new CATEGORY or COOKINGMETHOD is needed (or other value in a different field). This option makes me nervous.

View Replies !
A Form With 2 Drop Down Boxes.
Im in the process of trying to create my own calender and use php with it.

Im needing a script or something that basically lets me select the month and then displays another drop down box next to it with the number of days in that month.

Im pretty sure its java or something most likely but im not too sure. After the this is created its going to be submitted and allow the user to add a message to the date they selected with a textbox. Thats just a generalization of it. Can anyone help me out with the drop down boxes?

View Replies !
Generating Drop Down Boxes From Mysql
i'm using php with mysql. i need to be able to extract items out of my database and put them into a drop down box so that the data is dynamic.

In this example, i need to get all of the names from the name.office field into a drop down box to be used in further scripts/processess.

<html>
<head>
</head>
<body>

<?

$db = mysql_pconnect ("localhost", "XXXX", "XXXXX");

if (!$db)

{
echo "error: could not connect to database. please try again later";
exit;
}

mysql_select_db("XXXXXXX");
$query = "select name from office";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);

$row = mysql_fetch_array($result);

?>

</body>
</html>what goes here??? i have tried many things and not been able to get it to work.

View Replies !
Dynamic Dependent Drop Down Boxes
I need to build a dynamic page with 2 drop down boxes on it where the contents of the second drop down box are dependent upon the selection made in the first drop down box (the first box contains districts/regions and the second box contains towns/cities). The customer wants this to happen on a single screen but can this be done with PHP?

View Replies !
Dynamic Drop Down Boxes With Php Query
I need to build a dynamic page with 2 drop down boxes on it where the contents of the second drop down box are dependent upon the selection made in the first drop down box (the first box contains districts/regions and the second box contains towns/cities). The customer wants this to happen on a single screen but can this be done with PHP?

The above question is already answered by many people and they want me to use Javascript.
My doubt is the second box shoud query the list from a table in mysql using php. How do i do that?

View Replies !
Drop Down Boxes Change By Selection
what i'm trying to do is when a user selects a country say UK, all the uk states are displayed in another selection box below BUT if the US is selected all the us states are shown, this is on nion every friends/dating site just curious as to how this is done.

View Replies !
Dynamic Drop Down Boxes With Mysql
I'm working on a database project for a class and am having problems populating select boxes with a field from a mysql table.  The first thing that I'm trying to do is pull the field LastName from the table Faculty.  Then when the user selects the faculty member in the drop down box, it will then display all of the fields related to that faculty member...first and last name, title, office number etc and allow the user to edit those fields and then resubmit them to the database.

However I can't seem to get the drop down box to populate, so if anyone has any suggestions as to how to fix this I would love to hear them. Code:

View Replies !
Using Drop Down Boxes In Html Forms.
Basically im creating a file upload form, editted from the one on this site infact. but i now wish to create a bit of coding that goes into the form that would be a drop down menu box.

It needs to have 2 options: Video, Picture. Then when u press the upload button it has values that can be checked and turned into writing. how would i do this?

View Replies !
Drop Down Boxes Selected Value Against Variable
I have some drop down boxes being populated from a table:

print"<td><select name=project>";
if($project=mysql_fetch_array($pro))
{
do{
print"<option value='$project[proj_name]'>$project[proj_name]";
}
while($project=mysql_fetch_array($pro));
}
else{}

Now my question is, how can i make the value that is selected equal to another variable ie: $myrow[project], upon loading. Any ideas?

View Replies !
Edit Form Using Drop Down Boxes
I have a form that uses drop-down boxes to save information to a MySQL database using a php script I wrote. That works fine, but the problem comes when I am trying to edit the information in the database. I have an "edit form" that pulls the values from the database and displays the fields in the fields accordingly. I am having a hard time figuring out how to populate the drop-down boxes with the value from the database. I want the "option selected" tag to be the database and be able to still have the rest of the options to select from.

View Replies !
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:

View Replies !
Drop Down Boxes Selecting Selected Option
I have this code to allow me to get the selected option selected in the dropdown. The option is stored in url variable the code i currently have is selecting everything. I am doing something wrong? Code:

View Replies !
Filling Drop Down Boxes From MySQL Column
I am having problems filling a drop down box with data from a column in a MySQL table.
If anyone is able to see a problem with my coding could they please post where the problems are, and possibly how i would go about fixing it. Code:

View Replies !
Drop Down Boxes To Create Text Fields
I need a script that will create text boxes from a drop down box. So If I choose 6 from the drop down box and "enter family details" I want 6 text boxes to be created in my form on the next page....

View Replies !
Creating Two Drop Down Boxes On My Html Form That Are Populated With Data
I'm interested in creating two drop down boxes on my html form that are populated with data from a mysql database. The data for the first box is course titles and the data for the second is course sections. So far this is no problem. BUT, since the data in both select boxes is related. I would like the user to be able to select either/or and have the other select box automatically pick the associated value from the mysql database.

View Replies !
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?

View Replies !
Populating A Dropdown From A Database
I have put together a script that populates a dropdown menu from a database. My database contains a table called casinocredit, and it contains records that have been enterend over 2 different months (may and june). There is a field in the database that contains the date in this format: 2006-05-12 00:00:00

So The drop down is currently showing a month for each of those records. I was hoping that it would only display one. (the plan is when a user selects a month (say May) and hits submit, then I would display all of Mays records on a different page) See the image i have attached for a view of what is happening. Code:

View Replies !
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?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved