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




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




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?

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:

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

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:

Page State With Php?
I'm trying to create a site that pages through data retrieved from a database.

Let's say there are 12 items, and only 3 at a time can be displayed on a single
web page.

So the user needs to see some king of navigation control (a simple link would
suffice) that tells him there X items ahead and Y items behind. This way he can
page through all 12 items, 3 at a time, moving forward and backward.

Does this require some king of page/session state? How will my code know if
items 1 through 3 or 6 through 9 are currently displayed?

My guess is I'm not the first one who has needed to solve this kind of problem.

Search By Zipcode And State
I began in MySQL section (with your help I built a database) and now into the PHP stage of my project. Basically client wants a search capability on his site. He makes a product, sells to dealers, dealers sell directly to customers. He wants to be able to search dealer contact info by Zip and by State.

DevShed member Baddy was kind enough to offer the following script geared towards the State search. Following his lead, I developed the Zip portion- this is my first stab at PHP- and I basically mirrored whatever he did for State- I did for Zip! Code:

Saving Memory State
Is that possible to save memory state to a file? (i.e. the content of every variable)

Search City,State OR Zip Code
I would like to build a search box like the one found here at CitySearch.com .

Depending on what the user entered, the results would be sorted by (1) Zip Code, (2) City, or (3) State. If the user entered a Zip Code, I'd like to have all results be sorted by it since a Zip Code would represent the smallest geographical area. If no zip given sort by City and State. It would be easy enough to accomplish if the fields were seperated into different input fields, but I wanted to replicate the CitySearch box exactly because it doesn't take up much room on the page with only one input field.

Carry Logging State Across Pages
After login in on first page , how to carry logging state across pages. So, every login names will be displayed on the every pages. I use oracle as my back-end database.

Mainting State Inside A Function?
I have a question which no doubt will pose you people with nor problem whatsoever to help me with

I have written a function to display coherent error messages throughout my entire site

I pass it 2 vars, which contain only text
one is for the document's title, one for the error message in the body (ofcourse there is formatting etc, but thats all inside the function and CSS)

problem is, when the function gets called, it loses state, ie.: the generated page doesnt start the session properly, even though I do this inside the function

what can I do to prevent this? some elements of the site are only shown when a user is logged in, so the effects are rather dramatic ....

Multi-domain Session State
Does anybody have a solution on how to keep a PHP session alive across multiple domains ? A solution that does not involved writing the session ID in the URL because I can't do that.

SQL Error: , SQL State 00000 In SQLConnect
Client is running PHP 4.0.5. on Win2K Professonal SP2 outfitted with Apache 1.3.2. Trying to connect to an Access 2000 DB using a standard odbc_connect() call. The DB is fine, all looks good, but this error is returned:

Warning: SQL error: , SQL state 00000 in SQLConnect in c:program filesapache groupapachehtdocsstaffindex.php on line 10

Anyone seen this one before?

Setting Radio Button State
I am trying to set the state of a radio button. I do not see what I am
doing wrong. Sorry, I am new at this.. I need another set of eyes to
look at this snip of code. I am trying to set the radio button with this
link of code:

echo 'SCRIPT language=JavaScript
setCheckedValue("'.$_SESSION['abbr_letter'].'");</SCRIPT>' //?

<snip of code>

<?php
session_start();
if(!isset($_SESSION['abbr_letter'])) {
$_SESSION['abbr_letter'] = 'A'
}
require_once 'includes/config.inc.php'
require_once 'includes/header.inc.php'

if (xdebug_is_enabled())
echo "enable";
else
xdebug_enable();

//
// Start a Form
?>
<HTML>
<HEAD>
<link href="quotesCss.css" rel="stylesheet" type="text/css">
<SCRIPT TYPE="text/javascript">
<!--
// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(newValue) {
var len = document.author_abbrv.abbr_letter.length
for(var i = 0; i < len; i++)
{
document.author_abbrv.abbr_letter[i].checked = false;
if(document.author_abbrv.abbr_letter[i].value ==
newValue.toString())
{
document.author_abbrv.abbr_letter[i].checked = true;
}
}
}
-->

Validating A Country / State Form Input
I'm having trouble validating a state and country input. I didn't write it so I'm confused about why my code isn't working with it. Code:

Swap Image - Over State Not Retained - Because Of $_SERVER['PHP_SELF']
I have created a navigation menu with dreamweaver mx. On roll over the image is swapped and onpress the over-state is retained, so the user knows where he is. When using dummy links, like <a href="#"> it works. But in my case:

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

Using AJAX, How Can The Page Get State Infomation From Backgroud PHP Script?
I'm not familiar with web programming, but I have a problem here.

I have a page. When a user click one button on it, I will use AJAX to
request a PHP script which will do a bunch of tasks, asynchronously.
These tasks might take long time so I want to keep the user informed
of the progress. The problem is that only the PHP script knows the
progress, how can the web page gets these information from PHP script?

Mysql Select Question, Counting Total Recs For Each State?
I have a bunch of event records for various event dates.

I want to write an select state that shows the following

State Count
AZ 50
AR 2
AK 450
CO 75
CT 92

etc.

sorted by state of course.

Change From Win To Linux Server Caused Error SQL State 01S02
I'm using windows server before and there was no problem with the program. The problem happened when i adopt it into Linux servers. I'm using PHP 4.3.0, Ms-Access Database, and ODBC Driver Here's the error message :

Warning: odbc_exec(): SQL error: [unixODBC][Driver Manager]Option value changed, SQL state 01S02 in SQLExecDirect in /home/php/ranking/index.php on line 422 Code:

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:

Warning: SQL Error: [Caché ODBC][State : 08S01][Native Code 461]
I'm trying to connect PHP on Caché Database and I'm having a problem. This is the error:

Warning: SQL error: [Caché ODBC][State : 08S01][Native Code 461] [c:phpphp.exe] UNKNOWN MSG, SQL state 08S01 in SQLConnect in c:program filesapache groupapachehtdocscache_test.php on line 27

PHP knowed the ODBC Driver for InterSystem's Caché, but it stops in this problem. How can I resolve this?

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:


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