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




Dynamic Dropdown Lists


I am recoding a greeting card website.

I am using dropdowns as filters for items in a DB, so when the user picks "animals" from the "theme" dropdown, the returned cards all feature animals, and when the user picks "birthday" from the "message" option, the returned cards all feature birthday cards.

However, there are some combinations that don't return any results, for example "get well" "floral" cards. Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Dropdown Lists From A Mysql Db
Id like to load a drop down list from a mysql database using php3 and create a link to that record. Does anyone have any ideas?

Classes And Dropdown Lists
The class below works fine. The problem I have is there's a dropdown list in the middle of the loop. The dropdown list gets its data from another table in the database. Which goes through the same class. So I have a loop within a loop.

What I'm trying to do is ....

Create State-cty Dropdown Lists
I've gotten everything up and running except for this -- I'd like to
be able to have people have a dropdown list of cities in the US to use
(or wherever) and not have to input them manually into a text field.
When you do then there are issues of misspellings, etc.

Now I have a list of cities from each state that is a sample that
works in an html page. Problem is that it takes up 2 MB! Way too much
to load on a single page and I was wondering how this is accomplished
best -- do people use javascripts that can pull information from
another flat flie? Do people use PHP to connect to a mysql database
that might have a list of these fields and then reloads the page?

I'm really not sure of best options and would be grateful for anyone
to give me pointers or whether there are other examples and even
places to buy these databases (not likely but good to have if I decide
to do so.)

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:

Dynamic Dropdown?
I am posting a code for dynamic dropdown by Leon Atkinson, it works fine but i have a doubt: I tried to add another functionality to it where i got stuck! Once the city also gets selected from the second drop down i wanted that on clicking the submit button it should go to some html page wrt to the city choice. Code:

Dynamic Dropdown Box
im looking to have two drop down boxs one with makes of car and
the second drop down box to automatically populate with all the model
of that particular make of car. there are about 50 makes and upto 50
models per make.

I just would like to know the best way to do this - javascript or use
a database? it would be a lot of code todo it in javascript wouldnt
it?

Dynamic Fill Form Fields Depending On Dropdown Box
This question has probably already been asked, but let me ask again

I have a mysql database to which I connect with my php scripts. The
database contains articles. Name, Unit_Price and Reference

Now my client needs to order 5 items, click a button and a table with 5
lines and 3 columns appears (until now easy)

In the first column is a drop down box with a <select > and <options> in
which I store all possible names.

I would like than whenever the client changes one of the boxes (in my
case there are 5) the Unite_Price column and Reference column in the
line he just choose get automatically updated

Mailing Lists
I have searched in many places about how to set up a mailing list that is scalable yet no web sites seems to want to give out this info. I need to have this mailing list be effective even up to hundreds of thousands of users. Any advice/resources on how to set up this mailing list?

Email Lists
How would I go about making email lists? Someone who has something similar to what I want told me that they handle it with PHP. I'm not talking about a form where I can email an entire list, but rather an email GROUP, such that any time email went to URL from ANYONE that is a member of my site, it would come into domainname.com, and then sent back out to everyone in the "group".

Any info would be helpful. Is this possible with php? What is the email process? Right now I'm not even on a domain name on my own server.

Drop Down Lists
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>

Ordering Lists
I have developed a script (with help) that tries to order events stored in my .txt file by date. The .txt file looks like this: 1st|Jan|Meeting at House| 15th|Feb|Meeting at your House etc

The script orders the dates from lowest to highest but does not order dates before the 10th. Apparently 1st - 9th comes after 31st.. Code:

Maintaining Mailing Lists
I've few doubts; I'm asking two problem here.

1st, can we use PHP for maintaining mailing-lists. Say, we've 1000 users, need be e-mailed a subscription newsletter i.e. $message is same, loop through e-mail array in db.

2nd, Web site search. We maintain database after reading files using PHP and manipulate results from db.

Question is, if PHP is a solution for these problems, also, when users' ( 1 ), keywords' ( 2 ) dbs grow big! There is also a limit of a PHP script execution. In 1st case, PHP has to parse, suppose 10k subscribers, and generate 10k e-mail for sendmail program.

Is PHP feasible for such things. What else, is a better and professionally used solution. I don't know CGI? Perl?

Multiple Selection Lists?
i have a mutliple selection list on a form that goes like this

<select name='name' multiple size=6>";
echo "<option value='one'>one";
echo "<option value='two'>two";
echo "<option value='three'>three"; etc it works fine.

BUT how do u call it. For example say i selected option one and three. How do i call that on the next page so that ONE and THREE are stored.

Less-expensive Way To Set Up Defaults In Lists Etc?
I'm currently setting up default selections in <select> lists by
passing an array of those defaults as keys ( 'valuefoo' => true ) as
an argument to the function that sets up the list. Then, as I build
each <option>, I call array_key_exists ( thisoptionvalue,
arrayofdefaults ) to check whether to include the
'selected="selected"' string.

So the code looks something like

Routine ( array( 'valuefoo' => true, 'valuebar' => true ) ) ;
.....

function Routine ( $defaultvals )
{
for ( $i= etc. )
echo '<option....' . ( array_key_exists( 'curroptval',
$defaultvals ) ? 'selected="selected"' : '' ) . etc ' ;
}

(I've elided a lot of syntax, but you get the idea)

That seems slow and tedious. Does anyone know a cheaper way?

Quote's Invoices Lists...
I need someone to bounce some ideas off.

This is what I'm trying to do, I want to be able to create a script that
will spit out a quote based on the information filled in.

The part I'm stuck on is. Entering all the items in.

Ok, say I have a form, it starts off where you put in all the details
(eg, who the quote is for address phone no etc.)

Then there will be a list of items to go onto the quote.

Now this is the part I'm stuck on. I'm thinking maybe something like an
add new item button that opens a new window and then you enter in the
details for each item.
This then adds each item to the quote. Each item that is entered can be
added directly to the database. So what I'm thinking maybe is a popup
window that you fill in the details for each item, you hit submit, and
then it goes back to the origional quote page, but now with the item
added to the list.

Maybe is there java script where you can open a new window and then
refresh the parent window when the child is closed? this would then have
the items listed.

Mailing Lists Under Apache
I must develop mailing lists under Apache but I don't know how to do this, so, if someone knows how to do this.

Drop Down Lists And Variables
I have a dropdown list with values and I am having trouble getting the value chosen into a variable so that I can use it in an if statement.

Multiple Lists Selection
I am using a simple registration form that i made with the toolbox, but when I come to a multiple list to choose from (populated from the database) it doesn't work correctly. Of course, out of the multiple items selected only the last one gets inserted.

From what I have read, the selection must be turned into an array then looped for this to work. Is this correct? Next how would I code this to work right. If you let me know which code to post, I will post it.

Multiple Selection Lists &
I have 2 multiple selection lists. I am using javascript so that users can select items from list 1 and move them to list 2. When the user submits the form I need my php to get the values he has/she has in list 2...

I have done printf($_POST['list_2']) and it only shows one value, even when multiple are selected. I read that I need to change it's name to list_2[] but if I add the brackets to the name my javascript quits working.

Session Info And Pull Down Lists
i have a html pull down list (<SELECT etc etc <OPTION VALUE .....) and
i have the particular value the user last chose it to be in a
$_SESSION['value']. How do i set the selected item of the list to this
one? I can just add it in as the selected item of the list but then it
appears twice.

If You're Good With Arrays And Lists, This One's For You
I'm using PHP 4.4.4. Let's say I have two scalars, $list1 and $list2.
Both are comma separated lists of ordered, unsigned, unique integers.
An example would be

$list1 = "2,26,345";
$list2 = "3,4,26,35,525";

I am wondering if there is a short way of determining if all the
numbers in $list1 occur in $list2.

Creating Form 'select Lists' Using PHP
Is it by any chance possible to use mysql and php to auto create the
content for drop-down lists on forms by retrieving the values from a
database? The reason i ask is that on a site i am making i am asking
users to select from list (e.g. nationality) however i would like to
avoid typing out every possible value of which there are about 40
(which change). I would much prefer to keep a seperate table in my
database for the site.

Sorting Alphabetically Backwards Lists
This code runs @ http://www.ckoogle.com but the trouble is once I get
the list backwards, and in an array. I can't sort the new array into
alphabetical order. Anyone know a way to do it?

<?php

echo '<form action="index.php" method="post">'
echo '<textarea name="input" cols="12" rows="20">'
echo '</textarea><br>'
echo '<input type="submit" value="Submit">'
echo '</form>'

if( isset( $_POST["input"] )){
$my_array = $_POST["input"];
$my_array=strrev($my_array);
$my_array=explode("
", $my_array);
print_r($my_array);
sort($my_array);
print_r($my_array);
for($cnt=0; $cnt < count($my_array); $cnt++)
{
echo(strrev($my_array[$cnt]));
echo('<br>');
}
}
?>

How To Get Hotmail/Yahoo/Aol Contact Lists ?
is there anyone familiar with the part how does most of the match
making sites/schedular websites are accessing your Hotmail/Yahoo/Aol
address book and even inviting your friends rather choosing one by one
from your address book manually by you and make you be in the same
Network?

Detecting Checkboxes And Option Lists
I am trying to figure out how to detect a <Form> check box being checked in a PHP script.  Likewise, I am trying to figure out how to detect which option was chosen in a <option> list of drop-down items in a form. Code:

Auto-update Shopping Lists
I have a shopping list, or multiple shopping lists, that users and sort and add/delete items from.

I know how to add/move/delete items, but that is with a submit button. Is there a way, probably through AJAX, that the mySQL tables will be updated automatically as things are changed?

Pulling Options Lists From Mysql Tables
I've set up a form to load data into my db, but rather than hard code the options lists for three of the form fields, I'd like to pull that information from three lookup tables. This will allow whoever is inputting data to do a simple update for the three lookup tables, and speed enter the data into the form for the fourth (data) table without having to alter the code in the form.

Here's the wish list. The three lookup tables have a key field and a description field. I want to display the description field content for selection by the user in the form (for example, from EventClass table,

display "Single Pony" and return "1" to the CompClass field if Single Pony is selected
Display "Pair Pony" and return "2" to the CompClass field if Pair Pony is selected
display "Single Horse" and return "3" to the CompClass field if Single Horse" is selected
(etc.)

in EventScores), and have the key field content loaded with the data into the data table. Once I've figured the coding for one, I can duplicate the effort for the other two tables.

I have seen PHP coding inserted inside php code. I've never seen this particular practice in any other language I've programmed in. Is this how a connect/query is handled inside a form which is inside a php script? <?PHP <form><?PHP ?> </form> ?> ??

To put it another way, I want to retrieve the data from a table and display it in the options box of the form. Then, when a option value is selected, I want the key for that value returned to the table in which data is being loaded.

One Result Set Makes Two Lists With Same Keys And Values
I have a page with two drop-downs, each listing the same employee names
and their id's as the values. So they look like:
<select name="selection_1">
<option value="12">Curly</option>
<option value="8">Larry</option>
<option value="36">Moe</option>
</select>

....then further down the page:

<select name="selection_2">
<option value="12">Curly</option>
<option value="8">Larry</option>
<option value="36">Moe</option>
</select>

Currently I am doing this, which works but seems sloppy:

<select name="selection_1">
<?
while($employees=mysql_fetch_assoc($qry_rslt)) {
/* ADD NAMES TO DROPDOWN WITH emp_id's AS THEIR VALUES */
?><option
value="<?=$employees['emp_id']?>"><?=$employees['name']?></option><?

/* CREATE ANOTHER ARRAY WITH THE emp_id AS THE KEY */
$emp_list_2[$employees['emp_id']]=$employees['name'];
}
?>
</select>

Then on the second drop-down:

<select name="selection_2">
<?
foreach($emp_list_2 as $key => $emps) {
?>
<option value="<?=$key?>"><?=$emps?></option>
<?
}
?>
</select>

Saving Selection In Drop-down Lists In PHP After Page Reload?
I can't find an answer to my quesiton anywhere.

Given a drop-down list with USA states and other text fields I pass
this information for further processing via PHP. If any of the required

fields is empty, the PHP script would return an error and reload the
form page asking to fill out those fields. All entered information is
saved... except for the drop-down list selection. I tried to write a
Javascript function which is echoed by PHP, but interpolation of PHP
variables in the Javascript section gives a syntax error message in
Javascript.

The PHP script returns, e.g., an "AL" string for Alabama. Of course, I
don't want to write PHP code for each option to make it selected.

Looking For Dropdown Help
I have a dropdown in which i want it to open a soundfile when selected. So, how do I go about this. The form will get submitted, and through a series of conditional statements it will point the right selection to the right if statement. but what do I put in the if statement to get it to open a realplayer with my ram file?? Here's what I got so far.
Code: <FORM ACTION="<?=$_SERVER['PHP_SELF']?mode=changedropdown?>" METHOD="POST" NAME="sermondropdown">
<P>
<SELECT NAME="sermons" SIZE="1" onchange="this.form.submit();">
<OPTION VALUE="pleaseselectasermon">Please Select a Sermon
<OPTION VALUE="082403Daniel_1_1-8">August 24, 2003 Daniel 1:1-8
<OPTION VALUE="083103Daniel_1_1-8">August 31, 2003 Daniel 1:1-8
</SELECT></P>
</FORM>

<?
if('changedropdown' == $_GET['mode']) {
$selection = $_POST['sermons'];
if (?Daniel_1_1-8' == $selection) {

} elseif (?Daniel_1_1-8' == $selection) {

}
?>

Dropdown
I have a dynamic drop down that needs to be populated from different columns in a database. The problem I'm running into is that sometimes fields do not have a value. So I would rather those didn't print out. The code below prints out the blank fields.

I know I need to loop through and check for an empty value, but I'm drawing a blank on the how part. Code:

Dropdown Possible With PHP ?
i'm looking for a way to do the following :

1. selecting data from a MySQL database
2. putting one field into a dropdown
3. after selecting a value from the dropdown follow some more php code

step 1 is no problem, step 2 is no problem with the html select statement however this leaves me on the client side. After this i'm not able to return to the server side to execute some more php code, with the onchange attribute i can start some javascript but i want ( read need ) to use php code. Concrete question : is there a way to create a dropdown in pure php code ?

Dropdown Box
I currently have a dropdown box on a page. What I would like is that when a user selects something from the dropdown box it automatically changes the display of another box.

Value In A Dropdown
I have a piece of code where I get the player_id value from the url at the top of the page. Rather than this I want to get the value from variable named $player_one. Code:

Dropdown Box And A Query
Heres my situation:

In a form I want to read the categories listed in table $inv_table and present them in a dropdown window so the viewer can choose and add to a different table. The script below works with one glitch. There is a huge white space on the page above the dropdown box. This will get me by but it isn't too purty.

<td valign="bottom">
<a name="theform">
<select name="catname" size="1">
<?
{
$result = mysql_query("SELECT DISTINCT category FROM $inv_table ORDER by category",$db);
while ($myrow = mysql_fetch_array($result))
{
echo "<option>".$myrow["category"]."</option><br>";
}
}
?>
</SELECT>
</td>

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 Menu
I want to upload a feild values into a dropdownmenu. can anyone help me how to write in php code.

Dropdown - Default Value
I want to be able to have a drop down list that doesn't necessarily have the first item as the default. The content is being populated by PHP so I have no idea how to do it.

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.

Php Dropdown - Selected?
i'm using this to pull information from a database and display it in a dropdown list. The problem is I am using the name code when I goto the "Update" page, but i'm not sure how to add the "selected" field, that way what ever I saved in the database will load.

Example: I goto add and it add's the "id" of 7 to the field, when I load the page again it auto's back to 1 instead of clicking in-to 7 as thats whats already there... = ) Code:

MySQL Dropdown
Is there a way to make a dropdown by getting the options directly from the database? And I'm using this as a form so it has to have a name so I can call upon the value and do something to it.

Example to what I want to do:

- I have a database table named members and in that table, it has 3 columns - name, age, sex.

What I want to do is make a dropdown inside a <form> using the data from the database. And then when the person selects the name of the member and presses submit, it deletes the row with that name from the table and the database.

Change Dropdown Value
i've two dropdown fields

1) products - (mobile phone, camera, webcam, tv, dvd player and etc
2) accessories

how accessories field can be changed if visitor selects product.

for example: if visitor selects TV, accessories field should automatically changed with cable wire, electric board and etc (without reloading)

another example is www bestessays com/order.php
when you'll select "Thesis" from type of document, urgency and cost per page values will be changed.

Months Dropdown
I'm looking to do a dropdown with the months in the year starting with this month and going on for 12 months, ie. the selected month is April 2007 and the last month is March 2008, does anyone know how to do this using PHP?

Last 3 Months Dropdown
I need to come up with something that will take the current month, for example this month is april.
It would create a drop down list like

Feb 1 - feb 30
march 1 - march 30
April 1 - April 30
Basically the last 3 months, including this one.
Then I am going to need to save the month as the value, so I can pass it to the script so I know what date ranges I am looking for.
I can't think of a logical way to do this, and still account for the fact that some months have 29 days, some have 30, and some have 31.

Remember Selected Value DropDown
I am attempting to have a drop down menu that displays url from 1 table called links the same table also contains a name for the url. i.e. google.com = name and http://www.google.com = url The value of just the url from links is stored in a separate table called users in a field named search after form is submitted by user. Everything Posts correctly except when go back to edit the record and submit the form the drop down box does not retain the value of what had been previously selected although it is the correct record until form is updated when whatever value is currently in the drop down list will update the record.

I know the code is doing exactly what it is told to do, because I have no functionality in it to recall the value from the field search in the users table. I don't know if it is something I would have to add to the array or option value. I can get it to work if it is all hard coded, but I am attempting not to do this. I am pretty new to php mysql and any help is greatly appreciated.

This is the code I am working with that came mostly from a tutorial. PHP Code:

Maximum Dropdown Size
I have a strange issue with dropdowns. Using php4, mySQL5, Apache 2 on
a fast XP pro PC, I have a form which requires 5 dropdowns populated
with indentical values. I extract the values using SQL and populate 2
variables and use a for-next loop to create the dropdown. The dropdown
contains some 310 items! It works beautifully if I have 1 or 2
dropdowns but as soon as I add more it partially creates the 3rd and
just stops until it times out!
All 5 work because I have altered their positions but it always stops
part way through creating the 3rd dropdown.

I tried an alternative method by doing away with the variables and
constructing the dropdowns with a 'while' statement reading through
the results of my SQL and got exactly the same problem only 2 and a
bit dropdowns.

Stopping it running after a few seconds or several minutes makes no
difference, it seems to reach a certain point and just stop - no error
messages or anything!

I have tried increasing the resourses in my php.ini file but this also
made no difference.

Can anyone suggest an alternative or a fix?

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:

Advanced Dropdown Menu
I want to populate a dropdown menu with countries that are in one column of my table. I know how to do that, but I can't find how to eliminate multiple items. Some countries appear several times in different rows, but I only want each available country to be shown once in my dropdown list.

Mysql / Dropdown Menu
what i am trying to do is to make a system with a few input pages and edit and read pages..

so right now i got the input/edit/read pages working. (yay) But now I want to have on 1 input page a dropdown menu that reads its information from the database. and that if i go to the page i can select a value out of the db and submit that inside my form and that it reminds the value if i view or edit the page.

So what i got now is a little system that is able to add/remove/edit a value inside a field called "drop01"

Well now i got a other input page called "input01.php" inside this script i want to have the dropdown menu that reads its values from the "drop01" field. PHP Code:


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