View Single Post
  #1 (permalink)  
Old 05-04-2002, 02:49 PM
joyce's Avatar
joyce joyce is offline
Novice Webmaster
 
Join Date: Nov 2001
Location: Malaysia
Posts: 23
Rep Power: 0
joyce is on a distinguished road
retrieving select box..

i have a select box which display all the countries. when user register, they will need to choose they are from which country.

my problem is when retrieve out the country for display purpose. how am i suppose to do it?

this is part of the code:
PHP Code:
echo "<SELECT class=ft1 name=country>";
echo 
"<option>Please Select</option>";
echo 
"<option value=AF>Afghanistan</option>";
echo 
"<option value=AL>Albania</option>";
echo 
"<option value=DZ>Algeria</option>"
for normal select box, i will do something like this when retrieving..
PHP Code:
echo "<option ";
if (
$country == ''
  echo 
"selected";
echo 
">";

echo 
"<option value=AF ";
if (
$country == 'AF')
  echo 
"selected";
echo 
" >Afghanistan";

echo 
"<option value=AL ";
if (
$country == 'AL')
  echo 
"selected";
echo 
" >Albania";
echo 
"</option>"
i dowan to use this way because the country list is too long. if ihave to use this method, i wil have to do if statement for each and every country.

is there any alternative ways that i can do? shorter method?? better ways?? pls help!
Reply With Quote