Foros del Web » Programando para Internet » PHP »

Problema con if elseif

Estas en el tema de Problema con if elseif en el foro de PHP en Foros del Web. Hola, soy nuevo aquí. Quería saber si alguien podía ayudarme con mi problema. Estoy intentando modificar la siguiente web en wordpress www.worldwideeducation.eu Si mirais arriba ...
  #1 (permalink)  
Antiguo 28/07/2011, 03:21
 
Fecha de Ingreso: julio-2011
Mensajes: 4
Antigüedad: 12 años, 8 meses
Puntos: 0
Problema con if elseif

Hola, soy nuevo aquí. Quería saber si alguien podía ayudarme con mi problema. Estoy intentando modificar la siguiente web en wordpress www.worldwideeducation.eu
Si mirais arriba a la derecha pone Language: DE | EN | (y aquí quiero poner ES)

No sé si cuando miréis saldrá ES o no, el caso es que he conseguido ponerlo modificando la hoja stylesheet.css y header.php Pero los que hicieron la página pusieron la opción de que cuando está seleccionado un idioma, el otro idioma se vean las siglas en negrita. Mi problema es que al añadir el tercer idioma estoy intentando modificar el código, para que en vez de 2 variables haya 3, pero me da error.

Antes estaba así:

if($_SESSION['lang']!="en"){
$hightlightLang_de = '<span style="font-weight:bold;color:#3040a0;">DE</span>';
$hightlightLang_en = 'EN';
}else{
$hightlightLang_de = 'DE';
$hightlightLang_en = '<span style="font-weight:bold;color:#3040a0;">EN</span>';
}



Y yo he intentado modificarlo para que quede así:

if($_SESSION['lang']!="en"){
$hightlightLang_de = '<span style="font-weight:bold;color:#3040a0;">DE</span>';
$hightlightLang_en = 'EN';
$hightlightLang_es = '<span style="font-weight:bold;color:#3040a0;">ES</span>';
}elseif($_SESSION['lang']!="de"){
$hightlightLang_de = 'DE';
$hightlightLang_en = '<span style="font-weight:bold;color:#3040a0;">EN</span>';
$hightlightLang_es = '<span style="font-weight:bold;color:#3040a0;">ES</span>';
}else{
$hightlightLang_de = '<span style="font-weight:bold;color:#3040a0;">DE</span>';
$hightlightLang_en = '<span style="font-weight:bold;color:#3040a0;">EN</span>';
$hightlightLang_es = 'ES';
}


Pero me da error.
Espero haberme explicado bien, y que alguien pueda ayudarme.

Muchas gracias de antemano.
  #2 (permalink)  
Antiguo 28/07/2011, 03:26
 
Fecha de Ingreso: julio-2011
Mensajes: 4
Antigüedad: 12 años, 8 meses
Puntos: 0
Respuesta: Problema con if elseif

Quería añadir que ahora mismo he conseguido que se vean los 3, pero el de ES siempre se ve en negrita :S
  #3 (permalink)  
Antiguo 28/07/2011, 03:48
 
Fecha de Ingreso: julio-2011
Mensajes: 4
Antigüedad: 12 años, 8 meses
Puntos: 0
Respuesta: Problema con if elseif

Lo que viene despues a ese código es:

?>
<div id="langSwitch"><?php echo'Language';?>: <a href="<?php echo $currentPageLink."&amp;lang=de";?>"><?php echo $hightlightLang_de;?></a> | <a href="<?php echo $currentPageLink."&amp;lang=en";?>"><?php echo $hightlightLang_en;?></a> | <a href="<?php echo $currentPageLink."&amp;lang=es";?>"><?php echo $hightlightLang_es;?></a></div>
  #4 (permalink)  
Antiguo 28/07/2011, 04:09
Avatar de solhdeck  
Fecha de Ingreso: junio-2011
Mensajes: 87
Antigüedad: 12 años, 10 meses
Puntos: 32
Respuesta: Problema con if elseif

yo lo habría hecho así:
Código PHP:

if($_SESSION['lang']=="en"){
    
$hightlightLang_de '<span style="font-weight:bold;color:#3040a0;">DE</span>';
    
$hightlightLang_en 'EN';
    
$hightlightLang_es '<span style="font-weight:bold;color:#3040a0;">ES</span>';
}elseif(
$_SESSION['lang']=="de"){
    
$hightlightLang_de 'DE';
    
$hightlightLang_en '<span style="font-weight:bold;color:#3040a0;">EN</span>';
    
$hightlightLang_es '<span style="font-weight:bold;color:#3040a0;">ES</span>';
}elseif(
$_SESSION['lang']=="es"){
    
$hightlightLang_de '<span style="font-weight:bold;color:#3040a0;">DE</span>';
    
$hightlightLang_en '<span style="font-weight:bold;color:#3040a0;">EN</span>';
    
$hightlightLang_es 'ES';
}else{
    
$hightlightLang_de '<span style="font-weight:bold;color:#3040a0;">DE</span>';
    
$hightlightLang_en '<span style="font-weight:bold;color:#3040a0;">EN</span>';
    
$hightlightLang_es '<span style="font-weight:bold;color:#3040a0;">ES</span>';

Y debería funcionarte ^^
  #5 (permalink)  
Antiguo 28/07/2011, 04:20
 
Fecha de Ingreso: julio-2011
Mensajes: 4
Antigüedad: 12 años, 8 meses
Puntos: 0
Respuesta: Problema con if elseif

Mil gracias!!! No podrías haberlo resulto mejor!!! Quizás era una pregunta tonta, pero lo siento es que nunca he hecho nada de php ni nada, estoy aprendiendo investigando...ya sabes....prácticas en una empresa, da igual lo que hayas estudiado que al final acabas haciendo lo que necesiten...

Etiquetas: elseif, variables
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:14.