Help with <select option> adding more values..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ibom
Forum Newbie
Posts: 18
Joined: Sat Nov 28, 2009 3:05 am

Help with <select option> adding more values..

Post by ibom »

Can someone tell me how to add more values like "currency" when country is selected. the currency is auto insert in to the table currency.
EX. selecting USA -> USA, the country is insert into country table, and USD is insert into currency table....

Code: Select all

 
[color=#BF4080]Country: 
          <select name="country" id="select8">
            <option value="USA">USA</option>
            <option value="UK">UK</option>
            <option value="Egypt">Egypt</option>
            <option value="Jordan">Jordan</option>
            <option value="Kuwait">Kuwait</option>
            <option value="Lebanon">Lebanon</option>
            <option value="Libya">Libya</option>
            <option value="Marocco">Marocco</option>
            <option value="Oman">Oman</option>
            <option value="Qatar">Qatar</option>
            <option value="Saudi Arabia">Saudi Arabia</option>
            <option value="Syria">Syria</option>
            <option value="Tunisia">Tunisia</option>
            <option value="Turkey">Turkey</option>
            <option value="UAE">UAE</option>
            <option value="Yemen">Yemen</option>
            </select>[/[/color]code]
User avatar
dheeraj
Forum Commoner
Posts: 40
Joined: Fri Feb 06, 2009 11:54 am

Re: Help with <select option> adding more values..

Post by dheeraj »

just place one more value with the country name, separated by comma e.g.,

<option value="USA, Dollar">USA</option>
at the time of submission explode the selected value using explode method like

$con = explode(",", $_POST['xyz'])

so the result will be
$con[0] = "USA" * $con[1] = "Dollar"..
ibom
Forum Newbie
Posts: 18
Joined: Sat Nov 28, 2009 3:05 am

Re: Help with <select option> adding more values..

Post by ibom »

Hey agian

I'm using this type of connection.:

Code: Select all

 
 
mysql_query("INSERT INTO users
                  (`user_email`,`user_pwd`,`country`,`currency`,`transacc`,`joined`,`activation_code`,`full_name`,`Website`)
                  VALUES
                  ('$_POST[email]','$md5pass','$_POST[country]','$_POST[currency]','$_POST[transacc]',now(),'$activ_code','$_POST[full_name]','$_POST[Website]')") or die(mysql_error());
 
 
What is xzy.. Sorry i'm new at this php...
Post Reply