Re: Pedido

From: Date: Tue, 28 May 2002 20:41:51 +0000
Subject: Re: Pedido
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-23181@lists.php.net to get a copy of this message
Esto te puede ayudar. Es una lista de paises Hispanoparlantes + Brazil y USA metidos en una funcion Descripcion
fpais ("  ","3");     //// muestra el menu select con todos los paises.
fpais ("esp","3");     //// muestra el menu select con todos los paises pero con españa selecionada por defecto.
echo fpais ("esp","1");    //// Solo muestra el texto España
El menu select envia al formulario una cadena de 3 letrar para cada pais como estan en el array podrias cambiarlos. Osea que en la base quedaria para Argentina    "arg".
Saludos Adrian PD: tengo un select con todos los paise del mundo pero solo en html y tambien de las provincias argentinas. ////////// Paises pasados a variables //////////
$tex_arg                   = "Argentina";
$tex_bol                   = "Bolivia";
$tex_brz                   = "Brazil";
$tex_chl                   = "Chile";
$tex_col                   = "Colombia";
$tex_cri                   = "Costa Rica";
$tex_cub                   = "Cuba";
$tex_dom                   = "República Dominicana";
$tex_ecu                   = "Ecuador";
$tex_slv                   = "El Salvador";
$tex_esp                   = "España";
$tex_gtm                   = "Guatemala";
$tex_hnd                   = "Honduras";
$tex_mex                   = "México";
$tex_nic                   = "Nicaragua";
$tex_pan                   = "Panamá";
$tex_pry                   = "Paraguay";
$tex_per                   = "Perú";
$tex_pri                   = "Puerto Rico";
$tex_ury                   = "Uruguay";
$tex_ven                   = "Venezuela";
$tex_usa                   = "Estados Unidos";
$tex_nil                   = "No Listado";
/////// Funcion fpais Function fpais ($pais,$cod = "3") { global $tex_arg, $tex_bol, $tex_brz, $tex_chl, $tex_col, $tex_cri, $tex_cub, $tex_dom, $tex_ecu, $tex_slv, $tex_esp, $tex_gtm, $tex_hnd, $tex_mex, $tex_nic, $tex_pan, $tex_pry, $tex_per, $tex_pri, $tex_ury, $tex_ven, $tex_usa, $tex_nil, $msg_pais; if ($cod==1){
     $conv = array(     // devuelve el nombre completo para ser mostrado
       "arg" => $tex_arg,
       "bol" => $tex_bol,
       "brz" => $tex_brz,
       "chl" => $tex_chl,
       "col" => $tex_col,
       "cri" => $tex_cri,
       "cub" => $tex_cub,
       "dom" => $tex_dom,
       "ecu" => $tex_ecu,
       "slv" => $tex_slv,
       "esp" => $tex_esp,
       "gtm" => $tex_gtm,
       "hnd" => $tex_hnd,
       "mex" => $tex_mex,
       "nic" => $tex_nic,
       "pan" => $tex_pan,
       "pry" => $tex_pry,
       "per" => $tex_per,
       "pri" => $tex_pri,
       "ury" => $tex_ury,
       "ven" => $tex_ven,
       "usa" => $tex_usa,
       "nil" => $tex_nil,
     );
     $pais = Strtolower($pais);
     $pais = $conv[$pais];
     return $pais;
    } elseif ($cod==3){ // devuelve el menu select por defecto o con el pais de la base
       switch ($pais) {
        case "arg" :
           $selected1 = "selected";
           break;
        case "bol" :
           $selected2 = "selected";
           break;
        case "brz":
           $selected3 = "selected";
           break;
        case "chl":
           $selected4 = "selected";
           break;
        case "col":
           $selected5 = "selected";
           break;
        case "cri":
           $selected6 = "selected";
           break;
        case "cub":
           $selected7 = "selected";
           break;
        case "dom":
           $selected8 = "selected";
           break;
        case "ecu":
           $selected9 = "selected";
           break;
        case "slv":
           $selected10 = "selected";
           break;
        case "esp":
           $selected11 = "selected";
           break;
        case "gtm":
           $selected12 = "selected";
           break;
        case "hnd":
           $selected13 = "selected";
           break;
        case "mex":
           $selected14 = "selected";
           break;
        case "nic":
           $selected15 = "selected";
           break;
        case "pan":
           $selected16 = "selected";
           break;
        case "pry":
           $selected17 = "selected";
           break;
        case "per":
           $selected18 = "selected";
           break;
        case "pri":
           $selected19 = "selected";
           break;
        case "ury":
           $selected20 = "selected";
           break;
        case "ven":
           $selected21 = "selected";
           break;
        case "usa":
           $selected22 = "selected";
           break;
        case "nil":
           $selected23 = "selected";
           break;
        default:
           $selected1 = "selected";
        }
       echo "<select name=\"pais\" >";                                           ///////   Nombre de la variable que sara tomada por el formulario
           // echo "<option value=\"\"" . $selected . ">$msg_pais</option>";
           echo "<option value=\"arg\"" . $selected1 . ">$tex_arg</option>";
           echo "<option value=\"bol\"" . $selected2 . ">$tex_bol</option> ";
           echo "<option value=\"brz\"" . $selected3 . ">$tex_brz</option> ";
           echo "<option value=\"chl\"" . $selected4 . ">$tex_chl</option>";
           echo "<option value=\"col\"" . $selected5 . ">$tex_col</option>";
           echo "<option value=\"cri\"" . $selected6 . ">$tex_cri</option>";
           echo "<option value=\"cub\"" . $selected7 . ">$tex_cub</option>";
           echo "<option value=\"dom\"" . $selected8 . ">$tex_dom</option>";
           echo "<option value=\"ecu\"" . $selected9 . ">$tex_ecu</option>";
           echo "<option value=\"slv\"" . $selected10 . ">$tex_slv</option>";
           echo "<option value=\"esp\"" . $selected11 . ">$tex_esp</option>";
           echo "<option value=\"gtm\"" . $selected12 . ">$tex_gtm</option>";
           echo "<option value=\"hnd\"" . $selected13 . ">$tex_hnd</option>";
           echo "<option value=\"mex\"" . $selected14 . ">$tex_mex</option>";
           echo "<option value=\"nic\"" . $selected15 . ">$tex_nic</option>";
           echo "<option value=\"pan\"" . $selected16 . ">$tex_pan</option>";
           echo "<option value=\"pry\"" . $selected17 . ">$tex_pry</option>";
           echo "<option value=\"per\"" . $selected18 . ">$tex_per</option>";
           echo "<option value=\"pri\"" . $selected19 . ">$tex_pri</option>";
           echo "<option value=\"ury\"" . $selected20 . ">$tex_ury</option>";
           echo "<option value=\"ven\"" . $selected21 . ">$tex_ven</option>";
           echo "<option value=\"usa\"" . $selected22 . ">$tex_usa</option>";
           echo "<option value=\"nil\"" . $selected23 . ">$tex_nil</option>";
        echo "</select>";
        return;
   } }
?>

« previous php.general.es (#23181) next »