at first sorry if my english sux. Well I need a bit of help from you.
I got "Parse error: syntax error, unexpected 'if' (T_IF)" with the following code:
<?php
$ssimple='';
$smultiUno='';
$smultiDos='';
$deportes = array("Nadar","Fitness","Baloncesto");
$cine = array("StarWars","El señor de los Anillos","Matrix","Pulp Fiction");
$musica = array("Rock","Metal","Goth");
foreach ($deportes as $value) {
$ssimple.= "<option value=\"$value\" ".if(isset($deportes) and $deportes == $value) echo 'selected="selected"'.">$value</option>";
}
foreach ($cine as $value) {
$smultiUno.= "<option value=\"$value\"".if(isset($cine) and $cine == $value) echo 'selected="selected"'.">$value</option>";
}
foreach ($musica as $value) {
$smultiDos.= "<option value=\"$value\"".if(isset($musica) and $musica == $value) echo 'selected="selected"'.">$value</option>";
}
?>
How can it works?
Thanks to all! :)
Edit:
Finally get the answer:
<?php
$dep='';
$cin='';
$mus='';
$sdeportes = array("Natacion",
"Fitness",
"Baloncesto",
"Tenis",
"Patinaje Artistico");
$scine = array("StarWars",
"Matrix",
"Indiana Jones",
"Pulp Fiction",
"El Hobbit");
$smusica = array("Rock",
"Metal",
"Goth",
"Chill Step",
"Alternativa");
foreach ($sdeportes as $value) {
if(isset($deportes) and $value == $deportes){
$a = "selected=\"selected\"";
}else{
$a = '';
}
$dep .= "<option value =\"$value\" $a>$value</option>";
}
foreach ($scine as $value) {
if(isset($cine) and in_array($value, $cine)){
$a="selected=\"selected\"";
}else{
$a='';
}
$cin .= "<option value =\"$value\" $a>$value</option>";
}
foreach ($smusica as $value) {
if(isset($musica) and in_array($value, $musica)){
$a = "selected=\"selected\"";
}else{
$a='';
}
$mus .= "<option value =\"$value\" $a>$value</option> ";
}
?>
Thanks you all guys. Can close this topic :)