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.





A Dynamic Drop Down List


I need to create a dynamic drop down list. By this i mean that the webpage html form = select style will recieve all the values as based on a query to a mysql database. I have no problems quering the data base with PHP, But i need to make some kind of for loop that will add a new value to the selct form for each result from the database. my thought process go like this.

1. call data base to guery. (no problem)

2. make variable variables that will be created according to the number of results (these variables must be created according to results of query, not a problem i think)

3. make a form like this

<form action = ***** method = post>
<select name = ******>
<option value = "This is a query result"> This is a query result> //This is the part i need to using a for loop and variable variables
</select></form>

so my problem is part 3, cause is this all done in PHP, or if i had all these variables, can i do this in HTML? Can i make a for loop in PHP that would break into HTML during these parts?




View Complete Forum Thread with Replies

Related Forum Messages:
Dynamic Drop Down Box List - Php
I have two dropdown boxes. Two boxes have values from two different tables. They dont have any common field to relate with. I would like to display the values based on selecting the first combo box value. If i select first combo box value, then automaticlly the second drop down box value should be changed.

Code: ....

View Replies !
Dynamic Drop Down List
I have poured over these and other forums, but can't find out what I'm doing wrong. I've found a few threads that deal with what I'm trying to do, but they didn't fix the problem.

What I'm trying to do is populate a drop down list based on info in my mysql database table. I have a game number id (game_ID) I want to use as the 'value', and the game name (game_name_long) that I want to use as the actual entry in the list box.

Here is the code I am using that takes the data from the db and populates the drop down list box: Code:

View Replies !
Dynamic Drop-down List In Array
Q. How do I create a dynamically-generated drop-down list for use in
an array.

I'm using PHP with a MySQL database (through phpMyAdmin)

My database table is called com_courses, and I want to pull the
distinct 'title' fields and have them appear as a drop down menu for
the user to select in a form.

Here is my array, with (at the moment) manually-entered 'titles'
(which I now need to be dynamically generated from my database field:
'com_courses.title'

array (
"coursetitle",
"Course Title:",
$EXTRA_SELECTLIST,

array ("Report Writing", "Recruitment & Selection", "Presentation
Skills", "Essential Telephone Skills", "Time Managememt", "Customer
Care", "Other"),
0
),

I am not an experienced programmer, but can play around with php to
customize programs. I've read up on arrays (I bought a "Programming
with PHP and MySQL" book, but it just stops short of this problem). I
can't figure this one out.

View Replies !
Dynamic Drop-down List With Array - Question
Can anyone out there give me a pointer regarding creating a
dynamically-generated drop-down list connected to an array?

And is that question as clear as chocolate spread?

Here's what I've got. I'm using PHP and MySQL database. I'm customizing
some calendar software, and I want the user to fill in a form by
selecting a title from a drop-down list, generated by my MySQL
database. However, the program I'm customizing uses arrays, which is
where I'm stumped.

What do I need to add to this code to make the array of titles(eg
"report writing" etc) come from my database, rather than the
manually-entered values that you can see here.

The field I want to pull from is called com_courses.title

array (
"coursetitle",
"Course Title:",
$EXTRA_SELECTLIST,

array ("Report Writing", "Recruitment & Selection", "Presentation
Skills", "Essential Telephone Skills", "Time Managememt", "Customer
Care", "Other"),
0
),

I hope it's not cheeky to ask this,
BTW I bought a book on Programming with PHP and MySQL, but it doesn't
answer this question,

View Replies !
How Do I Change The Drop Down List So The Option Selected Last Time Is Then The Current One Shown In The Drop Down Box?
I have a drop down list with the town options 'Bury' and 'Ipswich' as
shown below.

When selecting one of the options, its value is passed to variable
$townsearch.

How do I change the drop down list so the option selected last time is
then the current one shown in the drop down box?

<body>

<?php $townsearch = $_get['town']; ?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">

<select size="1" name="town">

<option>ipswich</option>
<option>bury</option>
&nbsp;
</select>&nbsp;

<input type="submit" value="GO" />

</form>

View Replies !
Produce A List Of Tables Currently Within My Database And List Them In A Drop Down Box.
I need to produce a list of tables currently within my database and list them in a drop down box.

View Replies !
Php And Drop Down List
I am coding an email form on a site. A user enters their name and contact email and then selects from a drop down list to which particular email the message should be sent: User1, User2, User3. Then the user types out a message and hits submit. My problem is that I am unsure as to how to grab the selection in the drop down list and pull the selection and place it like this: "$selection@domain.com". Here is the php code:

View Replies !
Drop Down Box To A List Box
i have this drop down box that displays the relevant info from the table that its loading. But the drop down box isn't quite so wise to use if there hundreds of rows. So what i wanted to do was change it to a list box instead ... would any one know how to do that? Code:

View Replies !
Drop-down List
I populate a drop-down list like this:

echo "<select>";
foreach ( $ip_list as $var )
{
echo "<option>";
echo $var;
echo "</option>";
}
echo "</select>";

Is it possible to have the selection in the drop-down list default to a particular value? For example, let's say the complete list of values looks like this:

65.162.31.155
210.213.149.6
68.190.20.83
130.202.234.254
68.122.35.157

When the page is loaded, I want 68.190.20.83 to appear as the selected value in the drop-down list. Can this be done? Any suggestions or examples welcome.

View Replies !
A Drop Down List
im just starting out with PHP and im making a website that hosts some images. Its going great so far but I want to have a drop down that can show my albums. such as:

          <form name="form" id="form">
            <select name="jumpMenu" class="dropdown" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
              <option value="#" selected="selected">Browse</option>
              <option value="#">Ground - Concrete</option>
              <option value="#">Grass</option>
              <option value="#">Metal</option>
              <option value="#">Graffiti</option>
            </select>
          </form>

I want the entrys for this to come from my images folder. For example if i have images/holiday then holiday will come up in the list. Is there anywhere I can get an example of this?

View Replies !
Drop Down List
PHP Code:

<?
         $query = "SELECT `teacher_id`, `teacher_name` FROM teachers ORDER BY `teacher_name`";
         if ($r = mysql_query ($query)) { // Run the query.

    // Retrieve and print every record.
              while ($row = mysql_fetch_array ($r)) {
                      echo "<select name="teacher">";
                    echo "<option value="{$row['teacher_id']}">'".{$row['teacher_name']}."'</option>";
                    echo "</select>";
              }

          }.....

View Replies !
$row In A Drop Down List
I have a query. where I loop through courses, I get the id for each course, pass it to the next page then, I want to query the database again with it, how do I do this.

<select name="course">
<?PHP
$query = "SELECT * FROM courses ORDER BY course_name";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
  echo "<option id='".$row['id']."' >";
  echo $row['course_name'];
  echo ' ['.$row['course_date'].'] ' ; echo ' &pound'; echo $row['course_price']; // echo the number
  echo '</option>';
 }
?>
 </select>

Get the ID then pass it. how do I use it again on another page and another query.

View Replies !
Dynamic Drop Down Box
I gt a dynamic drop down box. here is the code:

echo "<select name="dropDwnBox">";
echo "<option size =30 selected>---Select Medium---</option>";
if( mysql_num_rows($getPaintQuery) )
{
while( $row = mysql_fetch_assoc($getPaintQuery) )
{
echo "<option>$row[medium]</option>";
}
}//end of if statement

it will display watercolor, pastel, gonache. so hw do i extract the value chosen by the user from this dynamic drop down box?

View Replies !
Dynamic Drop Down
I have the following drop down that is based on an array:

<select name=Yr>
foreach ($years as $key => $value) {
    echo "<option value=".$key;
          if ($key == $year) {
              echo " selected";
          }
    echo ">". $value;
}
echo   "</select>

I would like to re-write it in such a way that it will build a list of years from from -5 form not to 10+ from now, instead of using an array.

View Replies !
Get The Filenames And Put Them In A Drop Down List.
I want to read a directory for available files and then get the filenames and put them in a drop down list. Whatever the user will select will be the value of the variable $selected. I already found the code to read directories: Code:

View Replies !
2 Drop Down List Using MYSQL
I have a model table with the following fields: MODEL_ID, MAKE_ID, NAME.
And a make table with the following fields:
MAKE_ID, NAME.

The first drop down list (make) to select a make of a car i.e. Chevrolet, Ford. When a make is selected, then all the model for that paticular make appear in the second drop down list.

View Replies !
PHP And MYSQL Drop Down List
I need a script to create a drop down list which has vehicle makes. The vehicle make list should feed a vehicle model list so when I select a make all the models for the make appear in the model list. I have a make table which has MAKE_ID, make NAME and a model table which has MODEL_ID, MAKE_ID and model NAME.

I tried using a script using javascript array but wherever I have a query that pulls the NAME from the database there's always a carriage return after the NAME which messes up the javascript array. I'd rather do it all with PHP if possible. If not please give me one that works and I don't have to spend hours troubleshooting.

View Replies !
Very Simple Drop-down List...
Hi! I'm having a problem with a very simple drop-down list since the
page comes out with no elements in the drop-down but giving no errors.
This is the code:

<form name="year_search_form" method="post" action="results.php">
<select name="select_year" id="select_year">
<?
$query="SELECT * FROM table ORDER BY year";
$result = mysql_query($query) or die ("Error in query: $query. "
..mysql_error());

while ($line = mysql_fetch_array($result)) {
print ("<OPTION value=".$line['year']."></OPTION>"); }
?>
</select>
</form>

View Replies !
Drop Down List From An Array
I want the array to contain a valid year of birth for anyone between the ages of 16 and 80. I'm pretty sure this code is correct.(though it might be a bit sloppy to all you pros) Code:

View Replies !
Drop Down List With Months
I am trying to create a drop down list that has December 2006 as the first option and then goes up month and years till the current month and year (September 2007).

View Replies !
Putting List Into Drop Down
I am working on a directory of businesses which has 8 main categories and each category has several sub-categories. Example: Dining is a Category with Pizza, Fast Food, Chinese, etc. I have the sub-categories brought up in just a list on the left side of the page and when the user clicks on a sub-category it takes them from client_list.php to client_filter.php only showing businesses in that sub-category of the main category. 

So only pizza places listed under dining.  However, I want to change the list to a (form) select box and then have the user click on the sub-category they want and then it takes them to the client_filter.php page to list only those bussinesses in that sub-categorie.  So after that long explanation how do I change my code to do that. Here is my current code:

View Replies !
Insert From An Drop-down List
i have a table in wich i've inserted city's name.then i have an registration form in wich  i want to display an dropdown list with the cities from the table, and if one city is selected to be automaticly added in the second table. how can i do that?

View Replies !
Custom Drop Down List
I am trying to get categories from the database and show them in a drop down list showing root category then their sub category underneath. Code:

View Replies !
Folder List Drop-Down
I am developing a PHP/MySQL project and as part of my initial setup and configuration scripts, the users can select a skin for the application, and a variable value ($skin) is updated to set the current skin, this works ok on it's own, but currently the user must manually type the skin name in a free-text box.

Ideally this needs to be a drop-down option box, and I would like this to be populated by listing the sub-folders within the '/skins' folder, so that it's always up to date. The folder structure looks like this:

/skins
/skins/skin1
/skins/skin2
/skins/skin3

How can I use PHP to generate a list of the current sub-directories in 'skins' and populate the drop-down list?

View Replies !
How Do You Pass A Value From A Drop Down List?
I am completely new to this. I don't understand how to receive a value from a drop down list <select> menu. I have read many tutorials and none of them explain the process of receiving the sent data.

View Replies !
Drop Down List Of Months
I am trying to create a drop down list with 12 months as the contents. I need to be able to determine what the latest month is and then put the 11 months before into it (in the correct order). For example, it is September 2007 obviously at the moment, so that will need to be the last and latest month in the list. The other 11 will be in reverse order going back to August 2006.

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 !
Drop Down List Menu.
How do I make one item required on my "drop down" list menu? E.g., let's say that I want one state to be selected, how do I make this possible with PHP? My PHP skill is amature, but I do understand most.

View Replies !
Drop Down List Processing
I created a simple form in drop down list for USPS and FedEx. How do you process the drop down list?. If I select FedEx option, how do you retrieve it soI can use it in a query to find the Shipping Company store in my database. PHP Code:

<?php
   include ("header.php");
   print "Select shipping choice;
   
?>


<form action = "confirm.php" method = "post">                       
   <table border = 0>
    
      
       <tr>
      <td>Shipping choice </td>
         <select name="Shipper">

View Replies !
PHP To Display Drop Down List
I'd like to have 3 drop down lists connected.

Division
Department and
Section

Where the options of Department are dependent on what is selected in Division and the options of Section are dependent on what is selected in Department. So far, all the examples I've found have been using JavaScript. Can I do this in PHP as I have no knowledge of JavaScript at all.

View Replies !
Retaining Drop Down List Box Value
I currently have my drop down lists populated by a table from the sql database how can i retain the selected option once the form has been submitted. I know how to do this with textfields but cant figure out the dropdown lists because its being populated by a db. My code is as follows.

$cat = "<option value=>all</option>";
$cat .= "<option value=$row[id] $catselected>$row[name]</option>";

echo "<tr>
";
echo "<td class="classadd1"><div class="maininputleft">category</div></td>
";
echo "<td class="classadd2">
";
echo "<select name="in[catid]" style="width:200px;" onchange="changecat(this.options[this.selectedIndex].value)">$cat</select>";
echo "</td></tr>
";

View Replies !
Problem W/ Drop Down List
This current problem of mine is driving me nuts, there has to a solution. I'm farily new to PHP and have a couple questions which hopefully can be answered. I have two files, contact.php contains a form, with a drop down list.

When the user hits the submit button, they are directed toward tutorialcontact_result.php which catches any errors. If there is an error, on this page I provide a link back to contact.php. My first problem is: I'm trying to validate a drop down list using a regular expression as shown below: Code:

View Replies !
How To Add URL To Options In Drop Down List
I am have a drop down list, whose options are read in dynamically from a table in a MySQL database. one of the items being read in is an URL. I am unable to display this URL in the drop down list. The following is the code snippet I am using: Code:

View Replies !
Database Into A Drop Down List
I'm trying to pull data from my database and display this data in a drop down list. I have 3 drop down menus, when a sourcre is selected in the first menu. only the destinations available from that source should be displayed in the 2nd drop down and then the destinations of the next selection displayed in the 3rd drop down.

View Replies !
Search Via Drop Down List
How would I go about writing code so that a user could search by a drop down list, clicking on the date they want and then the page shows the record with date,availability and price from the database?

View Replies !
Assistance With Drop Down List
I need some assistance with coding a drop down list Code:

View Replies !
Duplicate Drop-Down-List
I have a table with countries and their associate dailing codes in rows (about 240) and I'm outputting them to the page in a loop to be placed in a drop down list.

In my form, I am needing the list 2x so I figured, just copy and paste the same code in the other location. Problem is, the first location renders perfectly, the second doesn't render at all. I wondering if it has to do with the connections that MySQL can have at one time. Here's the code for the loop: Code:

View Replies !
Drop Down List After A POST?
<SELECT name = "f_hello">
<OPTION value = 'H'>Hello</OPTION>"
<OPTION value = 'G'>Good-Bye</OPTION>"
</SELECT>

I can easily retrieve the f_hello variable which will containts H or G after a POST.

View Replies !
Dynamic Drop-down Menus
I am developing an on-line booking system, and am designing a script which creates a booking "area". An area has the following fields:

Area Name
Day start time (the time of day bookings can begin e.g 9 AM)
Booking Time Slot (the length of time for each time slot e.g 30 mins)
Day Finish Time (the time of day bookings must finish e.g 6 PM)

What i require is a method for locking down the users input so that the finish time is a list that is created that is divisable by the number of minutes used for a booking time slot . e.g. if the start time is 9 am and each booking time slot is 30 minutes, then the user must select a finish time which is divisable by 30 i.e. either on the hour or half past.

I have looked at several methods for doing this but cannot decide what would be suitable.
Ideally I want the user to be able to select the start time from a dropdown (static html would do) the select a booking time slot (again a static html dropdown would surfice) and then a dynamic dropdown be created with a list of Day Finish Times.

My questions are these:

Is this the right way to go about doing this - are drop downs my best option? If so, is calculating the day end time list the best way to go? Would javascript be more suitable, rather than a php form?

View Replies !
Dynamic Drop Down Menu
I'm having difficulties displaying the MakeModelID for a row selected from a drop down menu I've populated from a table combining three attributes (Make, Model and Specification - for example Ford Transit LWB 350 HR). What I require is to capture in a variable, such as $MakeModelID, the ID for that record selected. Code:

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 !
Sorting A Dynamic Drop Box
I have a drop box that is being populated by my database but, I would like to sort alphabetically. Is there anyway to do this? Also is there a way when an item in the drop box is selected that other fields in that database table will automatically appear in a seperate text box that I designate?

Like I want "cutomer name" to be the option to choose from in the drop box. When selected I want "customer address" and "customer phone" to appear in their own seperate text boxes.

View Replies !
Dynamic Drop Down Woes
I have a page where the user adds events to the organization calendar.
They have a set order in which they want the fields to appear. About halfway through the form a drop down box selects the type of event. A second drop down box brings up a list of performers with that event type.

That part works fine using javascript. The reload wipes out all the form fields except event type. I have tried adding the other fields to the request along with type but not working.

PHP Code: ....

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 !
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 !
Dynamic Drop Down Menu?
I have a customer table and I wish to be able to dynamically generate a drop down menu, to, for example, select the customer for which operations are to be performed.

after I have made the initial select statements, I assume i will then need to use a while loop

but this is where I am getting stuck....I am familiar with using while loops for creating tables dynamically but i'm not sure about drop downs. I just wish to show "company name" in the menu.

While it be something along the lines of....

while ( $row = mysql_fetch_array ( $sql )
option = $customer_name
etc..

View Replies !
Dynamic Drop Down Not Submitting
I have error checking on the code, line 13 of the code. I am simply trying to populate a dynamic drop down field with the country names from a table, then after selecting it submits the chosen drop down. But it is throwing an error and won't recognise the chosen country.

<TD><select name="country" value="<? echo $form->value("country"); ?>"
<?
$strSQL = "SELECT country FROM CountryTBL ORDER BY country";
$rs = mysql_query($strSQL);
$nr = mysql_num_rows($rs);
for ($i=0; $i<$nr; $i++) {
$r = mysql_fetch_array($rs);
echo "<OPTION
VALUE="".$r["country"]."">".$r["country"]."</OPTION>";
}
?>
>
<? echo $form->error("country"); ?>
</TD>

View Replies !
Dynamic Drop Down - QTY Field
Ive been searching these forums for the best part of an afternoon and cant see anything.
I have a QTY field in my table and the rows qty field has say a value of 5 What I want to do is populate a drop down with the values 1,2,3,4,5. so if the QTY for another row was 3 the drop down would be 1,2,3.

View Replies !
Dynamic Drop Down Menu
I'm trying to send emails to different users based on what is selected from a dynamic drop down list. Here is what I have that doesn't work: PHP Code:

<?php
$to = "me@myemail.com";
$subject = "current email test";
$message = "New RMA FORM FOR $rma";
$id = $_POST['status'];
$query = "select id from mytablename where id='$id'";
$result = mysql_query($query);
if (mysql_num_rows($result)==1){
    mail($to, $subject, $message);
}
?>

View Replies !
Chained Drop Down List Working Example
Could some PHP guru please help me? I looking for a good working
example of chained dropdown list.

View Replies !
2 Drop Down List Where Need Query Database
there is drop down list box linked to the database where it displays the state of a country and once the user clicks on the particular state, there purpose to be radio button displaying the locations available of that state, the location displayed in radio buttons are from the database. currently the source code i'm using is (which uses a submit button to query the database but i does not want the submit button it purpose to work using Code:

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 !

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