Populating Dropdown List
I am wanting to know how to populate the <SELECT> dropdown menu with all existing values from the DB and also have the value associated with that id selected. This is an updating area of my admin. Any ideas? Here's the code so far. At the moment it only retrieves the value assigned to that id. PHP Code:
View Complete Forum Thread with Replies
See Related Forum Messages: (Click on the Icon for short description)
Populating A List Box Or A Dropdown List Using Php And Odbc

I need to populate a list box and/or a dropdown list on a form. I have all the bits and pieces together, all bar the code which takes the result of a query and creates a list box.
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.
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 "Month" Dropdown Menu

I can get the current month to display in a text box by inserting value="<? print strftime("%B"); ?>"> into the code for that particular text box on a form but how can I populate a drop down with names of all the months with the current one being 'default' as it would be in the text box example?
Dropdown List

I have a Dropdown list with Select with 1, 2, 3, 4, after select on of them it bust to refresh the page to what you select but it don't do it. PHP Code:
Dropdown List

i am trying to get two dropdown lists working on a page. How do i go about this. For example, I have 1 table which holds countries and cities. When a user selects a country in the first dropdown list, i'd like the second dropdownlist populate with a list of cities etc. from my database.
Smarter Way Of Doing Dropdown List?

I've got a dropdown list that is acting as a filter on a table, so the user can select a value and the page is reloaded only showing the matching values from the database.
Now when the page reloads the dropdown was set to 'all' as it was first in the list, even if I'd selected a different value, this was confusing for users, so I added an initial <option> field which pulled the correct value from $_GET (code below) - however this is a little odd as it means the value appears twice!
Does anyone have a genius solution to this? I've seen a <select selected="yes"> sort of thing around, but I don't know how I can tell the php to add this value dynamically?
<select size='1' name='occupation'> <option>".$_GET['occupation']."</option> <option value='All'>All</option> <option value='Student'>Students</a></option> <option value='Professional'>Professional</option> <option value='Hobbyist'>Hobbyists</option> </select>
Autopopulate Dropdown List From Database

An events-registration page with a form containing a dropdown list for upcoming events, the events will be pulled from a table which is updated by...?
what i've gathered so far is that this can be done with PHP. I am a little unclear on the concept of how this is done. How does the updated information get input into the table?
1) can this be done (updating database) through a web interface by the client, or is it something i would have to do locally and then upload. If done by the client, can he delete/edit existing information--assuming he is not familiar with code.
2) what other things aside from html(good), sql(so-so), and php(newb) will i have to know?
i've seen a lot of good tutorials here and will have access to the necessary software. I just want to know if there is anything else i should know before i dive in head first without testing the PHP water, which i assume is frigid.
Dropdown List Of Files In Folder

I am preparing a form that includes a drop-down list consisting of the names of files in a certain folder on the server.
I only need to trap the file name (jpg), not the path and I'm not trying to upload the files or anything - simply allow the user to select one of a number of different image files (they're actually location maps).
Dropdown List - Trying To Get Default Populated From Db.

Nooby question but when I try and get this to work (it should identify which rows in the database have GK, MID, DEF, FWD against them and then put SELECTED into the option value to give a default of what the entry is currently) it just adds SELECTED to all the results as if $row["Position"] is returning true against all four conditions? What am I doing wrong? CODE:..
Cascade Dropdown Or Conditional List

I would like to create a conditional cascade form. based on the selection, it can display or not display an input form for the user to enter an string of text. then at the bottom of the page (or when a user submit) connect all the sections including the input field all together (it's like a story maker?)
Microsoft Access Dropdown List

l am building a new site using PHP which has a lot of pages pulling from an Access Database. I would like to have a dropdown list that pulls exhibitions from the database and then when the user selects one it shows the rest of the details from DB just below the dropdown list, hope that makes sense. Code:
Change List View To Dropdown Menu

Im working on a script that has to be change so a user can choose from a dropdown menu instead of a list that now is displayed. Here is the part that is insert on the index page.
Easy Comma-delimited List To Dropdown Box Converter

I was working on a simple converter when I realized that by not setting the id param of the option tag, it wasn't going to send the value of the dropdown box to my php script. I had this to start with: Code:
Dynamic Dropdown And Hardcode Dropdown In Select Form

I have plenty of examples of dynamic dropdown choices but none of hardcoded dropdown choices. The ultimate goal is to have a job with various tasks and to track the status of those tasks for a given job. I've used one of the tutorials here to begin the process. Below is the code I have to add work on a given task. Perhaps I actually need to "Update" a job as opposed to "add".
But the problem of the moment is I can't seem to hardcode one set of my options. This is the code I have: 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.
List Contents Of A Folder, Make List Of Links

Does anyone know how I can write a script that:
- reads in all the files in a particular directory - displays the file names in a html list and makes a link of them: <ul> <li><a href="filelocation1">filename 1</li> <li><a href="filelocation2">filename 1</li> <li><a href="filelocation3">filename 1</li> </ul>
etc.?
So basically it creates a list of links with the contents in that directory, so you can download them from there.
Get List Of Messages From One Table, Message List Indicator From

I have two tables. One has a list of messages left by users using fields named mbxno for the mailbox and msgno for the message number. I have another table that has mailbox settings for each user that contains a field named "messagelist" to indicate if they want to be included on the message list or not.
What I'm trying to create is a list of the most-recent messages with a lookup on the users table to indicate whether a message in the list should be included in the message list based on the user's mailbox settings.
SELECT messages.msgno, messages.mbxno, users.messagelist FROM messages, users WHERE (users.messagelist = Ƈ') ORDER BY msgno DESC LIMIT 100
What I'm getting, though is a list that looks like this:
mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1
I think what's happening is that I'm using the wrong type of join and more rows are being created than necessary.
If I add "DISTINCT" to the query, I get a list of the most-recent messages as I expect, but the "messsagelist" value is sometimes wrong (again, probably because the data is getting jumbled). For example, the messagelist value for the second row (2214) should be 0, not 1.
mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 2214 msgno: 0412141622 msglist: 1 mbxno: 2189 msgno: 0412141408 msglist: 1 mbxno: 0000 msgno: 0412141213 msglist: 1 mbxno: 0003 msgno: 0412141213 msglist: 1 mbxno: 2265 msgno: 0412132029 msglist: 1 mbxno: 0000 msgno: 0412131950 msglist: 1
How should I be doing this? If nothing else, what kind of join will work with a long list compared to a value from a short list?
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 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 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.
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 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 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:
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.
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..
Mailing List Manager, Send To List

I'm looking for a mailing list script (php) that has a function to let users to reach out to all recipient on the list by simple send the email to a specific maillist- address.
Mailman has this functionn but as a just got a webserver account I can't use mailman nor install it.
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 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 Table With Text File

My web hosting service uses phpMyAdmin and at the bottom of the screen iis an area where I can upload a text file to populate a table.
I have a table named groups with two fields: groups_idauto-increment primary groups_name
So how do I create my text file to populate this table?
I'm going to use MS Notepad.
If it's set to auto-increment, do I need to include the number? If so, does it start at 0 (zero)?
Would the file look like:
0,students 1,faculty 2, staff
or just
students faculty staff
PHP Not Populating Form Variables Passed Through POST Or GET

I"m running:
Windows Xp SP2 Apache2 PHP5 MySQL4
Everything seems fine and dandy, and I can do scripting on server side, but for some reason I cannot get data from a form to be put into a variable.
I have a simple form in an html page which submits, and in the php script that handles the input, none of the data in the form is going into the variables.
My php.ini file does have all the GPC's in place(ie variable_order, the way they get processed).
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.
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 ...
Populating Form From Database, Then Passing Results To Next Page

I have a multiple select input in a form that's being populated by a row from my database as such: <input type="checkbox" name="subm[]" value="$row[ID]">
That part is working fine as I can check the displayed page using View Source and see that the value is the correct row number from the database. It is then being submitted on a form by $_POST method to another page where I want to evaluate the checkboxes and display the contents of the entire row that corresponds to each value="$row[ID]" that have been checked. But I can't seem to get it to work. I'm having a problem passing the selected value. Can someone point me in the right direction?
$query = ("SELECT * FROM `table`"); $result = mysql_query($query);
print "<p>Data for Selections:"; print "<table border=2><tr><th>You chose:";
foreach ($_POST['subm'] as $value) { print "<tr><td>"; print "$row[ID]; "; print mysql_field_name($result, 1) . ": " . $row[name]."<br>"; print mysql_field_name($result, 2) . ": " . $row[address]."<br>"; print mysql_field_name($result, 3) . ": " . $row[city]."<br>"; print "</td></tr>"; print "</table> "; }
if (!isset($_POST['subm'])){ print "<p>No matching entry "; }
mysql_close();
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...
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:
Dynamically Populating Listboxes Based On Previous Selection

How do I populate the second listbox in this form based on the selection of the first listbox?
The first listbox is populated by this query: $year_query = "SELECT distinct year FROM bench_data"; The second listbox should essentially be populated by this: $industry_query = "SELECT distinct comp_desc FROM comp_desc, benc_data where $_POST['year']=bench_data.year and bench_data.comp_key=comp_desc.comp_key";
I know this is alot to ask, but please EXPLAIN the code. I am new and need the explanation elucidated and not just supplied code that will accomplish the goal. Code:
|