Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/09/2008, 11:36
edinjo
 
Fecha de Ingreso: septiembre-2008
Mensajes: 20
Antigüedad: 15 años, 7 meses
Puntos: 0
como funciona elseif o case???

Hola a todos, tengo un pequeño codigo en PHP, en el que quiero hacer multiples selecciones si se cumple una condición, lo estaba haciendo con elseif, pero cunado llevos muchos elseif ya no evalua, aca esta el codigo:

<?php
$myvar=$id;
switch($myvar){
if ($myvar==206254){
$nombre="NOELIA MARBELY AGUIRRE LINARE";
$grado="SEXTO PERITO EN ADMINISTRACION DE EMPRESAS";
$bimestre="CUARTO BIMESTRE 2008";
$mat=64;
$lenguaje=58;
$prom=($mat+$lenguaje)/2;
}elseif($myvar==206215){
$nombre="KEVIN JESUS CARDONA PRATT";
$grado="SEXTO PERITO EN ADMINISTRACION DE EMPRESAS";
$bimestre="CUARTO BIMESTRE 2008";
$mat=82;
$lenguaje=73;
$prom=($mat+$lenguaje)/2;
}elseif($myvar==206214){
$nombre="CLAUDIA KARINA CARRANZA RODRIGUEZ";
$grado="SEXTO PERITO EN ADMINISTRACION DE EMPRESAS";
$bimestre="CUARTO BIMESTRE 2008";
$mat=86;
$lenguaje=73;
$prom=($mat+$lenguaje)/2;
}elseif($myvar==207114){
$nombre="DIANA VIRGINIA CASCO PEREZ";
$grado="SEXTO PERITO EN ADMINISTRACION DE EMPRESAS";
$bimestre="CUARTO BIMESTRE 2008";
$mat=80;
$lenguaje=76;
$prom=($mat+$lenguaje)/2;
}elseif($myvar==206213){
$nombre="INGRID CHOI-BAN CHANG MENDEZ";
$grado="SEXTO PERITO EN ADMINISTRACION DE EMPRESAS";
$bimestre="CUARTO BIMESTRE 2008";
$mat=69;
.
.
.
.
.
}else{
$nombre="NO ENCONTRADO";
$grado="NO ENCONTRADO";
$bimestre="NO ENCONTRADO";
$mat=0;
$lenguaje=0;
$prom=($mat+$lenguaje)/2;
}
echo ("\n$nombre");
echo $nombre;
echo $grado;
echo $bimestre;
echo $mat;
echo $lenguaje;
echo ($mat+$lenguaje)/2;

trate de hacerlo con case switch pero tampoco logro que me funcione... Nota: la variable $id, es ingresada desde otra pagina php cuando se llama a la otra pagina que es la que contiene el codigo anterior. Espero su ayuda, gracias:

aca esta el codigo desde donde se ingresa el dato que adopta la variable id:

html>
<style type="text/css">
<!--
.Estilo1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.Estilo3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 24px; color: #FFFFFF; }
-->
</style>
<body>
<p>
<?php
if ($submit) {
// process form
while (list($name, $value) = each($HTTP_POST_VARS)) {
echo "$name = $value<br>\n";
}
} else{
// display form
?>
<form method="post" action="datos2.php">
</p>
<table width="784" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="83" colspan="5" bgcolor="#71C6FF"><img src="image003.gif" width="119" height="83"></td>
</tr>
<tr>
<td colspan="5" bgcolor="#0066CC"><span class="Estilo3">Visualizador de Notas </span></td>
</tr>
<tr>
<td height="35" colspan="3" bgcolor="#71C6FF"><span class="Estilo1">Ingrese su numero de carnet, es el codigo que esta en su talonario de pagos (debe tener 6 digitos) </span>---------------------------------------------------------------------------------------&gt;</td>
<td width="91" bgcolor="#71C6FF"><div align="center">
<input name="id" type="Text" size="6" maxlength="6">
</div></td>
<td width="83" bgcolor="#71C6FF"><div align="center">
<input type="Submit" name="submit" value="Ver notas">
</div></td>
</tr>
<tr>
<td height="200" colspan="5" valign="top" bgcolor="#CCCCFF"><div align="justify" class="Estilo1">Su numero de carnet es el codigo que se encuentra en el talonario de pagos de colegiaturas, si usted no lo sabe debe de comunicarse al colegio para que lo proporcionen. Si sus notas a&uacute;n no estan completas, por favor siga visitando este sitio y verificar constantemente. </div></td>
</tr>

<tr>
<td width="541">&nbsp;</td>
<td width="8">&nbsp;</td>
<td width="61">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<p><br>
</p>
</form>
<?php
}
?>
</body>
</html>