...

View Full Version : drop down from data base



bigredkacy
06-09-2005, 06:16 AM
Im trying to create a dropdown that is getting the infomation for a row in the database. i have this


<?php
echo "Select Your Country <select name='Country'><option value='Select your country' SELECTED>Select your country</option>";
echo "</select>";
?>

for example my db has a row with the countries name of "ZW (Zimbabwe)" in the database rcnitror_zipcode.countries.name

database info = for more help


--
-- Table structure for table `countries`
--

CREATE TABLE `countries` (
`shortname` char(2) NOT NULL default '',
`name` varchar(32) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `countries`
--

INSERT INTO `countries` VALUES ('BE', 'BE (Belgium)');
INSERT INTO `countries` VALUES ('BD', 'BD (Bangladesh)');
INSERT INTO `countries` VALUES ('BB', 'BB (Barbados)');
INSERT INTO `countries` VALUES ('BA', 'BA (Bosnia and Herzegovina)');
INSERT INTO `countries` VALUES ('AZ', 'AZ (Azerbaijan)');
INSERT INTO `countries` VALUES ('AW', 'AW (Aruba)');
INSERT INTO `countries` VALUES ('AU', 'AU (Australia)');
INSERT INTO `countries` VALUES ('AT', 'AT (Austria)');
INSERT INTO `countries` VALUES ('AS', 'AS (American Samoa)');
INSERT INTO `countries` VALUES ('AR', 'AR (Argentina)');
INSERT INTO `countries` VALUES ('AQ', 'AQ (Antarctica)');
INSERT INTO `countries` VALUES ('AO', 'AO (Angola)');
INSERT INTO `countries` VALUES ('AN', 'AN (Netherlands Antilles)');
INSERT INTO `countries` VALUES ('AM', 'AM (Armenia)');
INSERT INTO `countries` VALUES ('AL', 'AL (Albania)');
INSERT INTO `countries` VALUES ('AI', 'AI (Anguilla)');
INSERT INTO `countries` VALUES ('AG', 'AG (Antigua and Barbuda)');
INSERT INTO `countries` VALUES ('AF', 'AF (Afghanistan)');
INSERT INTO `countries` VALUES ('AE', 'AE (United Arab Emirates)');
INSERT INTO `countries` VALUES ('AD', 'AD (Andorra)');
INSERT INTO `countries` VALUES ('CM', 'Cameroon');
INSERT INTO `countries` VALUES ('CA', 'Canada');
INSERT INTO `countries` VALUES ('CV', 'Cape Verde');
INSERT INTO `countries` VALUES ('KY', 'Cayman Islands');
INSERT INTO `countries` VALUES ('CF', 'Central African Republic');
INSERT INTO `countries` VALUES ('TD', 'Chad');
INSERT INTO `countries` VALUES ('CL', 'Chile');
INSERT INTO `countries` VALUES ('CN', 'China');
INSERT INTO `countries` VALUES ('CX', 'Christmas Island');
INSERT INTO `countries` VALUES ('CC', 'Cocos (Keeling) Islands');
INSERT INTO `countries` VALUES ('CO', 'Colombia');
INSERT INTO `countries` VALUES ('KM', 'Comoros');
INSERT INTO `countries` VALUES ('CG', 'Congo');
INSERT INTO `countries` VALUES ('CD', 'Congo, the Democratic Republic o');
INSERT INTO `countries` VALUES ('CK', 'Cook Islands');
INSERT INTO `countries` VALUES ('CR', 'Costa Rica');
INSERT INTO `countries` VALUES ('HR', 'Croatia');
INSERT INTO `countries` VALUES ('CY', 'Cyprus');
INSERT INTO `countries` VALUES ('CZ', 'Czech Republic');
INSERT INTO `countries` VALUES ('AF', 'Afghanistan');
INSERT INTO `countries` VALUES ('AF', 'Afghanistan');
INSERT INTO `countries` VALUES ('AL', 'Albania');
INSERT INTO `countries` VALUES ('DZ', 'Algeria');
INSERT INTO `countries` VALUES ('AS', 'American Samoa');
INSERT INTO `countries` VALUES ('AD', 'Andorra');
INSERT INTO `countries` VALUES ('AO', 'Angola');
INSERT INTO `countries` VALUES ('AI', 'Anguilla');
INSERT INTO `countries` VALUES ('AG', 'Antigua and Barbuda');
INSERT INTO `countries` VALUES ('AR', 'Argentina');
INSERT INTO `countries` VALUES ('AM', 'Armenia');
INSERT INTO `countries` VALUES ('AW', 'Aruba');
INSERT INTO `countries` VALUES ('AU', 'Australia');
INSERT INTO `countries` VALUES ('AT', 'Austria');
INSERT INTO `countries` VALUES ('AZ', 'Azerbaijan');
INSERT INTO `countries` VALUES ('BS', 'Bahamas');
INSERT INTO `countries` VALUES ('BH', 'Bahrain');
INSERT INTO `countries` VALUES ('BD', 'Bangladesh');
INSERT INTO `countries` VALUES ('BB', 'Barbados');
INSERT INTO `countries` VALUES ('BY', 'Belarus');
INSERT INTO `countries` VALUES ('BE', 'Belgium');
INSERT INTO `countries` VALUES ('BZ', 'Belize');
INSERT INTO `countries` VALUES ('BJ', 'Benin');
INSERT INTO `countries` VALUES ('BM', 'Bermuda');
INSERT INTO `countries` VALUES ('BT', 'Bhutan');
INSERT INTO `countries` VALUES ('BO', 'Bolivia');
INSERT INTO `countries` VALUES ('BW', 'Botswana');
INSERT INTO `countries` VALUES ('BA', 'Boznia and Herzegovina');
INSERT INTO `countries` VALUES ('BR', 'Brazil');
INSERT INTO `countries` VALUES ('BN', 'Brunei Darussalam');
INSERT INTO `countries` VALUES ('BG', 'Bulgaria');
INSERT INTO `countries` VALUES ('BF', 'Burkina Faso');
INSERT INTO `countries` VALUES ('BI', 'Burundi');
INSERT INTO `countries` VALUES ('KH', 'Cambodia');
INSERT INTO `countries` VALUES ('CM', 'Cameroon');
INSERT INTO `countries` VALUES ('CA', 'Canada');
INSERT INTO `countries` VALUES ('CV', 'Cape Verde');
INSERT INTO `countries` VALUES ('KY', 'Cayman Islands');
INSERT INTO `countries` VALUES ('CF', 'Central African Republic');
INSERT INTO `countries` VALUES ('TD', 'Chad');
INSERT INTO `countries` VALUES ('CL', 'Chile');
INSERT INTO `countries` VALUES ('CN', 'China');
INSERT INTO `countries` VALUES ('CX', 'Christmas Island');
INSERT INTO `countries` VALUES ('CC', 'Cocos (Keeling) Islands');
INSERT INTO `countries` VALUES ('CO', 'Colombia');
INSERT INTO `countries` VALUES ('KM', 'Comoros');
INSERT INTO `countries` VALUES ('CG', 'Congo');
INSERT INTO `countries` VALUES ('CD', 'Congo, the Democratic Republic o');
INSERT INTO `countries` VALUES ('CK', 'Cook Islands');
INSERT INTO `countries` VALUES ('CR', 'Costa Rica');
INSERT INTO `countries` VALUES ('HR', 'Croatia');
INSERT INTO `countries` VALUES ('CY', 'Cyprus');
INSERT INTO `countries` VALUES ('CZ', 'Czech Republic');
INSERT INTO `countries` VALUES ('BR', 'Brazil');
INSERT INTO `countries` VALUES ('BN', 'Brunei Darussalam');
INSERT INTO `countries` VALUES ('BG', 'Bulgaria');
INSERT INTO `countries` VALUES ('BF', 'Burkina Faso');
INSERT INTO `countries` VALUES ('BI', 'Burundi');
INSERT INTO `countries` VALUES ('KH', 'Cambodia');
INSERT INTO `countries` VALUES ('CM', 'Cameroon');
INSERT INTO `countries` VALUES ('CA', 'Canada');
INSERT INTO `countries` VALUES ('CV', 'Cape Verde');
INSERT INTO `countries` VALUES ('KY', 'Cayman Islands');
INSERT INTO `countries` VALUES ('CF', 'Central African Republic');
INSERT INTO `countries` VALUES ('TD', 'Chad');
INSERT INTO `countries` VALUES ('CL', 'Chile');
INSERT INTO `countries` VALUES ('CN', 'China');
INSERT INTO `countries` VALUES ('CX', 'Christmas Island');
INSERT INTO `countries` VALUES ('CC', 'Cocos (Keeling) Islands');
INSERT INTO `countries` VALUES ('CO', 'Colombia');
INSERT INTO `countries` VALUES ('KM', 'Comoros');
INSERT INTO `countries` VALUES ('CG', 'Congo');
INSERT INTO `countries` VALUES ('CD', 'Congo, the Democratic Republic o');
INSERT INTO `countries` VALUES ('CK', 'Cook Islands');
INSERT INTO `countries` VALUES ('CR', 'Costa Rica');
INSERT INTO `countries` VALUES ('HR', 'Croatia');
INSERT INTO `countries` VALUES ('CY', 'Cyprus');
INSERT INTO `countries` VALUES ('CZ', 'Czech Republic');
INSERT INTO `countries` VALUES ('BF', 'BF (Burkina Faso)');
INSERT INTO `countries` VALUES ('BG', 'BG (Bulgaria)');
INSERT INTO `countries` VALUES ('BH', 'BH (Bahrain)');
INSERT INTO `countries` VALUES ('BI', 'BI (Burundi)');
INSERT INTO `countries` VALUES ('BJ', 'BJ (Benin)');
INSERT INTO `countries` VALUES ('BM', 'BM (Bermuda)');
INSERT INTO `countries` VALUES ('BN', 'BN (Brunei Darussalam)');
INSERT INTO `countries` VALUES ('BO', 'BO (Bolivia)');
INSERT INTO `countries` VALUES ('BR', 'BR (Brazil)');
INSERT INTO `countries` VALUES ('BS', 'BS (Bahamas)');
INSERT INTO `countries` VALUES ('BT', 'BT (Bhutan)');
INSERT INTO `countries` VALUES ('BV', 'BV (Bouvet Island)');
INSERT INTO `countries` VALUES ('BW', 'BW (Botswana)');
INSERT INTO `countries` VALUES ('BY', 'BY (Belarus)');
INSERT INTO `countries` VALUES ('BZ', 'BZ (Belize)');
INSERT INTO `countries` VALUES ('CA', 'CA (Canada)');
INSERT INTO `countries` VALUES ('CC', 'CC (Cocos (Keeling) Islands)');
INSERT INTO `countries` VALUES ('CF', 'CF (Central African Republic)');
INSERT INTO `countries` VALUES ('CG', 'CG (Congo)');
INSERT INTO `countries` VALUES ('CH', 'CH (Switzerland)');
INSERT INTO `countries` VALUES ('AD', 'AD (Andorra)');
INSERT INTO `countries` VALUES ('AE', 'AE (United Arab Emirates)');
INSERT INTO `countries` VALUES ('AF', 'AF (Afghanistan)');
INSERT INTO `countries` VALUES ('AG', 'AG (Antigua and Barbuda)');
INSERT INTO `countries` VALUES ('AI', 'AI (Anguilla)');
INSERT INTO `countries` VALUES ('AL', 'AL (Albania)');
INSERT INTO `countries` VALUES ('AM', 'AM (Armenia)');
INSERT INTO `countries` VALUES ('AN', 'AN (Netherlands Antilles)');
INSERT INTO `countries` VALUES ('AO', 'AO (Angola)');
INSERT INTO `countries` VALUES ('AQ', 'AQ (Antarctica)');
INSERT INTO `countries` VALUES ('AR', 'AR (Argentina)');
INSERT INTO `countries` VALUES ('AS', 'AS (American Samoa)');
INSERT INTO `countries` VALUES ('AT', 'AT (Austria)');
INSERT INTO `countries` VALUES ('AU', 'AU (Australia)');
INSERT INTO `countries` VALUES ('AW', 'AW (Aruba)');
INSERT INTO `countries` VALUES ('AZ', 'AZ (Azerbaijan)');
INSERT INTO `countries` VALUES ('BA', 'BA (Bosnia and Herzegovina)');
INSERT INTO `countries` VALUES ('BB', 'BB (Barbados)');
INSERT INTO `countries` VALUES ('BD', 'BD (Bangladesh)');
INSERT INTO `countries` VALUES ('BE', 'BE (Belgium)');
INSERT INTO `countries` VALUES ('BF', 'BF (Burkina Faso)');
INSERT INTO `countries` VALUES ('BG', 'BG (Bulgaria)');
INSERT INTO `countries` VALUES ('BH', 'BH (Bahrain)');
INSERT INTO `countries` VALUES ('BI', 'BI (Burundi)');
INSERT INTO `countries` VALUES ('BJ', 'BJ (Benin)');
INSERT INTO `countries` VALUES ('BM', 'BM (Bermuda)');
INSERT INTO `countries` VALUES ('BN', 'BN (Brunei Darussalam)');
INSERT INTO `countries` VALUES ('BO', 'BO (Bolivia)');
INSERT INTO `countries` VALUES ('BR', 'BR (Brazil)');
INSERT INTO `countries` VALUES ('BS', 'BS (Bahamas)');
INSERT INTO `countries` VALUES ('BT', 'BT (Bhutan)');
INSERT INTO `countries` VALUES ('BV', 'BV (Bouvet Island)');
INSERT INTO `countries` VALUES ('BW', 'BW (Botswana)');
INSERT INTO `countries` VALUES ('BY', 'BY (Belarus)');
INSERT INTO `countries` VALUES ('BZ', 'BZ (Belize)');
INSERT INTO `countries` VALUES ('CA', 'CA (Canada)');
INSERT INTO `countries` VALUES ('CC', 'CC (Cocos (Keeling) Islands)');
INSERT INTO `countries` VALUES ('CF', 'CF (Central African Republic)');
INSERT INTO `countries` VALUES ('CG', 'CG (Congo)');
INSERT INTO `countries` VALUES ('CH', 'CH (Switzerland)');
INSERT INTO `countries` VALUES ('AD', 'AD (Andorra)');
INSERT INTO `countries` VALUES ('AE', 'AE (United Arab Emirates)');
INSERT INTO `countries` VALUES ('AF', 'AF (Afghanistan)');
INSERT INTO `countries` VALUES ('AG', 'AG (Antigua and Barbuda)');
INSERT INTO `countries` VALUES ('AI', 'AI (Anguilla)');
INSERT INTO `countries` VALUES ('AL', 'AL (Albania)');
INSERT INTO `countries` VALUES ('AM', 'AM (Armenia)');
INSERT INTO `countries` VALUES ('AN', 'AN (Netherlands Antilles)');
INSERT INTO `countries` VALUES ('AO', 'AO (Angola)');
INSERT INTO `countries` VALUES ('AQ', 'AQ (Antarctica)');
INSERT INTO `countries` VALUES ('AR', 'AR (Argentina)');
INSERT INTO `countries` VALUES ('AS', 'AS (American Samoa)');
INSERT INTO `countries` VALUES ('AT', 'AT (Austria)');
INSERT INTO `countries` VALUES ('AU', 'AU (Australia)');
INSERT INTO `countries` VALUES ('AW', 'AW (Aruba)');
INSERT INTO `countries` VALUES ('AZ', 'AZ (Azerbaijan)');
INSERT INTO `countries` VALUES ('BA', 'BA (Bosnia and Herzegovina)');
INSERT INTO `countries` VALUES ('BB', 'BB (Barbados)');
INSERT INTO `countries` VALUES ('BD', 'BD (Bangladesh)');
INSERT INTO `countries` VALUES ('BE', 'BE (Belgium)');
INSERT INTO `countries` VALUES ('BF', 'BF (Burkina Faso)');
INSERT INTO `countries` VALUES ('BG', 'BG (Bulgaria)');
INSERT INTO `countries` VALUES ('BH', 'BH (Bahrain)');
INSERT INTO `countries` VALUES ('BI', 'BI (Burundi)');
INSERT INTO `countries` VALUES ('BJ', 'BJ (Benin)');
INSERT INTO `countries` VALUES ('BM', 'BM (Bermuda)');
INSERT INTO `countries` VALUES ('BN', 'BN (Brunei Darussalam)');
INSERT INTO `countries` VALUES ('BO', 'BO (Bolivia)');
INSERT INTO `countries` VALUES ('BR', 'BR (Brazil)');
INSERT INTO `countries` VALUES ('BS', 'BS (Bahamas)');
INSERT INTO `countries` VALUES ('BT', 'BT (Bhutan)');
INSERT INTO `countries` VALUES ('BV', 'BV (Bouvet Island)');
INSERT INTO `countries` VALUES ('BW', 'BW (Botswana)');
INSERT INTO `countries` VALUES ('BY', 'BY (Belarus)');
INSERT INTO `countries` VALUES ('BZ', 'BZ (Belize)');
INSERT INTO `countries` VALUES ('CA', 'CA (Canada)');
INSERT INTO `countries` VALUES ('CC', 'CC (Cocos (Keeling) Islands)');
INSERT INTO `countries` VALUES ('CF', 'CF (Central African Republic)');
INSERT INTO `countries` VALUES ('CG', 'CG (Congo)');
INSERT INTO `countries` VALUES ('CH', 'CH (Switzerland)');
INSERT INTO `countries` VALUES ('AD', 'AD (Andorra)');
INSERT INTO `countries` VALUES ('AE', 'AE (United Arab Emirates)');
INSERT INTO `countries` VALUES ('AF', 'AF (Afghanistan)');
INSERT INTO `countries` VALUES ('AG', 'AG (Antigua and Barbuda)');
INSERT INTO `countries` VALUES ('AI', 'AI (Anguilla)');
INSERT INTO `countries` VALUES ('AL', 'AL (Albania)');
INSERT INTO `countries` VALUES ('AM', 'AM (Armenia)');
INSERT INTO `countries` VALUES ('AN', 'AN (Netherlands Antilles)');
INSERT INTO `countries` VALUES ('AO', 'AO (Angola)');
INSERT INTO `countries` VALUES ('AQ', 'AQ (Antarctica)');
INSERT INTO `countries` VALUES ('AR', 'AR (Argentina)');
INSERT INTO `countries` VALUES ('AS', 'AS (American Samoa)');
INSERT INTO `countries` VALUES ('AT', 'AT (Austria)');
INSERT INTO `countries` VALUES ('AU', 'AU (Australia)');
INSERT INTO `countries` VALUES ('AW', 'AW (Aruba)');
INSERT INTO `countries` VALUES ('AZ', 'AZ (Azerbaijan)');
INSERT INTO `countries` VALUES ('BA', 'BA (Bosnia and Herzegovina)');
INSERT INTO `countries` VALUES ('BB', 'BB (Barbados)');
INSERT INTO `countries` VALUES ('BD', 'BD (Bangladesh)');
INSERT INTO `countries` VALUES ('BE', 'BE (Belgium)');
INSERT INTO `countries` VALUES ('BF', 'BF (Burkina Faso)');
INSERT INTO `countries` VALUES ('BG', 'BG (Bulgaria)');
INSERT INTO `countries` VALUES ('BH', 'BH (Bahrain)');
INSERT INTO `countries` VALUES ('BI', 'BI (Burundi)');
INSERT INTO `countries` VALUES ('BJ', 'BJ (Benin)');
INSERT INTO `countries` VALUES ('BM', 'BM (Bermuda)');
INSERT INTO `countries` VALUES ('BN', 'BN (Brunei Darussalam)');
INSERT INTO `countries` VALUES ('BO', 'BO (Bolivia)');
INSERT INTO `countries` VALUES ('BR', 'BR (Brazil)');
INSERT INTO `countries` VALUES ('BS', 'BS (Bahamas)');
INSERT INTO `countries` VALUES ('BT', 'BT (Bhutan)');
INSERT INTO `countries` VALUES ('BV', 'BV (Bouvet Island)');
INSERT INTO `countries` VALUES ('BW', 'BW (Botswana)');
INSERT INTO `countries` VALUES ('BY', 'BY (Belarus)');
INSERT INTO `countries` VALUES ('BZ', 'BZ (Belize)');
INSERT INTO `countries` VALUES ('CA', 'CA (Canada)');
INSERT INTO `countries` VALUES ('CC', 'CC (Cocos (Keeling) Islands)');
INSERT INTO `countries` VALUES ('CF', 'CF (Central African Republic)');
INSERT INTO `countries` VALUES ('CG', 'CG (Congo)');
INSERT INTO `countries` VALUES ('CH', 'CH (Switzerland)');
INSERT INTO `countries` VALUES ('AD', 'AD (Andorra)');
INSERT INTO `countries` VALUES ('AE', 'AE (United Arab Emirates)');
INSERT INTO `countries` VALUES ('AF', 'AF (Afghanistan)');
INSERT INTO `countries` VALUES ('AG', 'AG (Antigua and Barbuda)');
INSERT INTO `countries` VALUES ('AI', 'AI (Anguilla)');
INSERT INTO `countries` VALUES ('AL', 'AL (Albania)');
INSERT INTO `countries` VALUES ('AM', 'AM (Armenia)');
INSERT INTO `countries` VALUES ('AN', 'AN (Netherlands Antilles)');
INSERT INTO `countries` VALUES ('AO', 'AO (Angola)');
INSERT INTO `countries` VALUES ('AQ', 'AQ (Antarctica)');
INSERT INTO `countries` VALUES ('AR', 'AR (Argentina)');
INSERT INTO `countries` VALUES ('AS', 'AS (American Samoa)');
INSERT INTO `countries` VALUES ('AT', 'AT (Austria)');
INSERT INTO `countries` VALUES ('AU', 'AU (Australia)');
INSERT INTO `countries` VALUES ('AW', 'AW (Aruba)');
INSERT INTO `countries` VALUES ('AZ', 'AZ (Azerbaijan)');
INSERT INTO `countries` VALUES ('BA', 'BA (Bosnia and Herzegovina)');
INSERT INTO `countries` VALUES ('BB', 'BB (Barbados)');
INSERT INTO `countries` VALUES ('BD', 'BD (Bangladesh)');
INSERT INTO `countries` VALUES ('BE', 'BE (Belgium)');
INSERT INTO `countries` VALUES ('BF', 'BF (Burkina Faso)');
INSERT INTO `countries` VALUES ('BG', 'BG (Bulgaria)');
INSERT INTO `countries` VALUES ('BH', 'BH (Bahrain)');
INSERT INTO `countries` VALUES ('BI', 'BI (Burundi)');
INSERT INTO `countries` VALUES ('BJ', 'BJ (Benin)');
INSERT INTO `countries` VALUES ('BM', 'BM (Bermuda)');
INSERT INTO `countries` VALUES ('BN', 'BN (Brunei Darussalam)');
INSERT INTO `countries` VALUES ('BO', 'BO (Bolivia)');
INSERT INTO `countries` VALUES ('BR', 'BR (Brazil)');
INSERT INTO `countries` VALUES ('BS', 'BS (Bahamas)');
INSERT INTO `countries` VALUES ('BT', 'BT (Bhutan)');
INSERT INTO `countries` VALUES ('BV', 'BV (Bouvet Island)');
INSERT INTO `countries` VALUES ('BW', 'BW (Botswana)');
INSERT INTO `countries` VALUES ('BY', 'BY (Belarus)');
INSERT INTO `countries` VALUES ('BZ', 'BZ (Belize)');
INSERT INTO `countries` VALUES ('CA', 'CA (Canada)');
INSERT INTO `countries` VALUES ('CC', 'CC (Cocos (Keeling) Islands)');
INSERT INTO `countries` VALUES ('CF', 'CF (Central African Republic)');
INSERT INTO `countries` VALUES ('CG', 'CG (Congo)');
INSERT INTO `countries` VALUES ('CH', 'CH (Switzerland)');
INSERT INTO `countries` VALUES ('AD', 'AD (Andorra)');
INSERT INTO `countries` VALUES ('AE', 'AE (United Arab Emirates)');
INSERT INTO `countries` VALUES ('AF', 'AF (Afghanistan)');
INSERT INTO `countries` VALUES ('AG', 'AG (Antigua and Barbuda)');
INSERT INTO `countries` VALUES ('AI', 'AI (Anguilla)');
INSERT INTO `countries` VALUES ('AL', 'AL (Albania)');
INSERT INTO `countries` VALUES ('AM', 'AM (Armenia)');
INSERT INTO `countries` VALUES ('AN', 'AN (Netherlands Antilles)');
INSERT INTO `countries` VALUES ('AO', 'AO (Angola)');
INSERT INTO `countries` VALUES ('AQ', 'AQ (Antarctica)');
INSERT INTO `countries` VALUES ('AR', 'AR (Argentina)');
INSERT INTO `countries` VALUES ('AS', 'AS (American Samoa)');
INSERT INTO `countries` VALUES ('AT', 'AT (Austria)');
INSERT INTO `countries` VALUES ('AU', 'AU (Australia)');


+ more

devosc
06-09-2005, 06:30 AM
You mean something like:

options = array();
query database
while database results (fetch_assoc)
options[] = <option value="shortname">name</option>
$string = implode('',options);

try working the above into real php and post back if stuck somewhere.

bigredkacy
06-09-2005, 06:35 AM
i dont understand sorry :*(

can you like fill it in with like the info and ill edit the db info or what?

devosc
06-09-2005, 06:44 AM
http://us4.php.net/mysql_query
$result = mysql_query('select * from countries');
$_cOptions = array();
while($row = mysql_fetch_assoc($result)) {
$_cOptions[] = "<option value=\"{$row['shortname']}\">{$row['name']}</option>";
}
$cOptions = implode("\n",$_cOptions);

<?php
echo "Select Your Country <select name='Country'><option value='Select your country' SELECTED>Select your country</option>";
echo $cOptions;
echo "</select>";
?>

Yakisoba
06-09-2005, 06:52 AM
I think you want to do something like this...

I assume that you have already extablished the connection to the db.

after the connection is made you need to query the database and store the values in a resultset:



$select = "SELECT name FROM countries ORDER BY name";

//the result of the query will be stored here
$rs = mysql_query($select) or die(mysql_error());



Then you have to "echo" the .html that will construct the <select> menu.
Note: the "while" loop will iterate through the result set and create a new <option> for each row:




echo "<label>Please select your country: ";
echo "<select name='country' id='country'>";


//Each row in the rs will be an option
while ($row = mysql_fetch_array($rs))
{
echo "<option value='".$row['name']."'>".$row['name']."</option>";
}
}

//this closes the open .html tags
echo "</label>";
echo "</select>";
echo "</form>";



After that it's also a good idea to clear the result set and close the db:




//free memory
mysql_free_result($rs);

//close the db
mysql_close();





Hope that helps.

Yak

bigredkacy
06-09-2005, 07:45 AM
and all this can go into my one php file?

heres the code



<?php
if(isset($_GET['submit'])){
mysql_connect("localhost", "rcnitror_kacy", "");
mysql_select_db("rcnitror_zipcode");
$query = "insert into dealers(`address1`,`country`,`name`,`phone`,`url`,`fulltime`,`onroad`,`offroad`,`fax`,`email`,`zip`, `hours`,`carry`,`order`) values ('".$_GET["Address1"]."','".$_GET["Country"]."','".$_GET["Name"]."','".$_GET["Phone"]."','".$_GET["URL"]."','".$_GET["fulltime"]."','".$_GET["onroad"]."','".$_GET["offroad"]."','".$_GET["Fax"]."','".$_GET["Email"]."','".$_GET["Zip"]."','".$_GET["hours"]."','".$_GET["carry"]."','".$_GET['order']."')";
mysql_query($query) or die(mysql_error());
if(!$query){
echo "Sorry but there was an error when processing your request. Please try again. " . mysql_error();
}
else
{
echo "Success! <a href='search.html'>Return to search</a>";
}
}
else
{
?>
<body>
<form action='adddealer.php' method='get'>
<?php
echo "Select Your Country <select name='Country'><option value='Select your country' SELECTED>Select your country</option>";
echo "</select>";
?>
<br>
Dealer Name: <input type='text' name='Name'><br>
Hours: <input type='text' name='Hours'><br>
Telephone Number: <input type='text' name='Phone'><br>
Fax Number: <input type='text' name='Fax'><br>
Email Address: <input type='text' name='Email'><br>
Website: <input type='text' name='URL'><br>
Postcode: <input type='text' name='Zip'><br>
Address: <input type='text' name='Address1'><br>
Full time hobby shop:
<input type='radio' name='fulltime' value='yes'>Yes
<input type='radio' name='fulltime' value='No'>No<br>
On-road track:
<input type='radio' name='onroad' value='Yes'>Yes
<input type='radio' name='onroad' value='No'>No<br>
Off-road track:
<input type='radio' name='offroad' value='Yes'>Yes
<input type='radio' name='offroad' value='No'>No<br>
Carry Integy parts in stock:
<input type='radio' name='carry' value='Yes'>Yes
<input type='radio' name='carry' value='No'>No<br>
Special order Integy parts:
<input type='radio' name='order' value='Yes'>Yes
<input type='radio' name='order' value='no'>No<br>

<input type='submit' name='submit'>
</form>
</body>
</html>

<?php } ?>


is there anyway you can insert it in there. i dont know how in notpad

Yakisoba
06-09-2005, 08:04 AM
Yes. The best way to insert it in there (notepad) is to cut and paste the code to the spot where you want the button to appear.

It would look something like this:




<?php
if(isset($_GET['submit'])){
mysql_connect("localhost", "XXXXXXX", "XXXXXX");
mysql_select_db("rcnitror_zipcode");
$query = "insert into dealers(`address1`,`country`,`name`,`phone`,`url`,`fulltime`,`onroad`,`offroad`,`fax`,`email`,`zip`, `hours`,`carry`,`order`) values ('".$_GET["Address1"]."','".$_GET["Country"]."','".$_GET["Name"]."','".$_GET["Phone"]."','".$_GET["URL"]."','".$_GET["fulltime"]."','".$_GET["onroad"]."','".$_GET["offroad"]."','".$_GET["Fax"]."','".$_GET["Email"]."','".$_GET["Zip"]."','".$_GET["hours"]."','".$_GET["carry"]."','".$_GET['order']."')";
mysql_query($query) or die(mysql_error());
if(!$query){
echo "Sorry but there was an error when processing your request. Please try again. " . mysql_error();
}
else
{
echo "Success! <a href='search.html'>Return to search</a>";
}
}
else
{
?>
<body>
<form action='adddealer.php' method='get'>
<?php

$select = "SELECT name FROM countries ORDER BY name";

//the result of the query will be stored here
$rs = mysql_query($select) or die(mysql_error());

echo "<label>Please select your country: ";
echo "<select name='country' id='country'>";


//Each row in the rs will be an option
while ($row = mysql_fetch_array($rs))
{
echo "<option value='".$row['name']."'>".$row['name']."</option>";
}
}

//this closes the open .html tags
echo "</label>";
echo "</select>";
echo "</form>";

echo "Select Your Country <select name='Country'><option value='Select your country' SELECTED>Select your country</option>";
echo "</select>";
?>
<br>
Dealer Name: <input type='text' name='Name'><br>
Hours: <input type='text' name='Hours'><br>
Telephone Number: <input type='text' name='Phone'><br>
Fax Number: <input type='text' name='Fax'><br>
Email Address: <input type='text' name='Email'><br>
Website: <input type='text' name='URL'><br>
Postcode: <input type='text' name='Zip'><br>
Address: <input type='text' name='Address1'><br>
Full time hobby shop:
<input type='radio' name='fulltime' value='yes'>Yes
<input type='radio' name='fulltime' value='No'>No<br>
On-road track:
<input type='radio' name='onroad' value='Yes'>Yes
<input type='radio' name='onroad' value='No'>No<br>
Off-road track:
<input type='radio' name='offroad' value='Yes'>Yes
<input type='radio' name='offroad' value='No'>No<br>
Carry Integy parts in stock:
<input type='radio' name='carry' value='Yes'>Yes
<input type='radio' name='carry' value='No'>No<br>
Special order Integy parts:
<input type='radio' name='order' value='Yes'>Yes
<input type='radio' name='order' value='no'>No<br>

<input type='submit' name='submit'>
</form>
</body>
</html>

<?php

//free memory
mysql_free_result($rs);

//close the db
mysql_close();

?>


Yak

bigredkacy
06-09-2005, 08:40 PM
ok i did this now its duplicating the field... www.rcnitroracing.com/zipcode/adddealer.php
anything?



<?php
if(isset($_GET['submit'])){
mysql_connect("localhost", "rcnitror_kacy", "k");
mysql_select_db("rcnitror_zipcode");
$query = "insert into dealers(`address1`,`country`,`name`,`phone`,`url`,`fulltime`,`onroad`,`offroad`,`fax`,`email`,`zip`, `hours`,`carry`,`order`) values ('".$_GET["Address1"]."','".$_GET["Country"]."','".$_GET["Name"]."','".$_GET["Phone"]."','".$_GET["URL"]."','".$_GET["fulltime"]."','".$_GET["onroad"]."','".$_GET["offroad"]."','".$_GET["Fax"]."','".$_GET["Email"]."','".$_GET["Zip"]."','".$_GET["hours"]."','".$_GET["carry"]."','".$_GET['order']."')";
mysql_query($query) or die(mysql_error());
if(!$query){
echo "Sorry but there was an error when processing your request. Please try again. " . mysql_error();
}
else
{
echo "Success! <a href='search.html'>Return to search</a>";
}
}
else
{
?>
<body>
<form action='adddealer.php' method='get'>
<?php
mysql_connect("localhost", "rcnitror_kacy", "k");
mysql_select_db("rcnitror_zipcode");
$select = "SELECT name FROM countries ORDER BY name";

//the result of the query will be stored here
$rs = mysql_query($select) or die(mysql_error());

echo "<label>Please select your country: ";
echo "<select name='country' id='country'>";


//Each row in the rs will be an option
while ($row = mysql_fetch_assoc($rs))
{
echo "<option value='".$row['name']."'>".$row['name']."</option>";
}
}

//this closes the open .html tags
echo "</label>";
echo "</select>";
echo "</form>";
?>
<br>
Dealer Name: <input type='text' name='Name'><br>
Hours: <input type='text' name='Hours'><br>
Telephone Number: <input type='text' name='Phone'><br>
Fax Number: <input type='text' name='Fax'><br>
Email Address: <input type='text' name='Email'><br>
Website: <input type='text' name='URL'><br>
Postcode: <input type='text' name='Zip'><br>
Address: <input type='text' name='Address1'><br>
Full time hobby shop:
<input type='radio' name='fulltime' value='yes'>Yes
<input type='radio' name='fulltime' value='No'>No<br>
On-road track:
<input type='radio' name='onroad' value='Yes'>Yes
<input type='radio' name='onroad' value='No'>No<br>
Off-road track:
<input type='radio' name='offroad' value='Yes'>Yes
<input type='radio' name='offroad' value='No'>No<br>
Carry Integy parts in stock:
<input type='radio' name='carry' value='Yes'>Yes
<input type='radio' name='carry' value='No'>No<br>
Special order Integy parts:
<input type='radio' name='order' value='Yes'>Yes
<input type='radio' name='order' value='no'>No<br>

<input type='submit' name='submit'>
</form>
</body>
</html>

<?php

//free memory
mysql_free_result($rs);

//close the db
mysql_close();

?>

Yakisoba
06-10-2005, 04:00 AM
Sorry, I don't quite understand the question...

What field is duplicating?

I went to your link...the drop-down menu appears fine.

Yak

Also - not sure if you mind, but, you might want to remove your DB login and password from the code you post(ed).

bigredkacy
06-10-2005, 04:11 AM
I got it. THANKS SO MUCH FOR THE HELP.... <3



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum