Академический Документы
Профессиональный Документы
Культура Документы
switch
5
Con la sentencia switch podemos ejecutar unas u otras instrucciones dependiendo del valor
de una variable.
expresión) con muchos valores diferentes, y ejecutar una parte de código distinta
switch.
Formato:
switch(dato)
break;
break;
break; ………………
default: instruccion(es);
Vasquez Contreras, Rafael Daniel Paá gina 1
Analista Programador
Email:Rafofoxbasic2000@hotmail.com
};
<?php
$NumeroMes=$_POST['TxtNMes'];
if(is_numeric($NumeroMes))
switch($NumeroMes)
case 1:$Nom="Enero";break;
case 2:$Nom="Febrero";break;
case 4:$Nom="Abril";break;
case 5:$Nom="Mayo";break;
case 6:$Nom="Junio";break;
case 7:$Nom="Julio";break;
case 8:$Nom="Agosto";break;
case 9:$Nom="Setiembre";break;
case 10:$Nom="Octubre";break;
case 11:$Nom="Noviembre";break;
case 12:$Nom="Diciembre";break;
else
$Mensa="Error no es número";
?>
<html>
<body>
<h1>
<center>
</center>
</h1>
<div>
>"/>
</div>
</form>
</body>
</html>
$numero=$_POST['TxtNumero'];
if(is_numeric($numero))
switch($numero)
case 1:$Precio=12000;
$Descuento=10;
break;
$Descuento=20;
break;
case 3:$Precio=19000;
$Descuento=30;
break;
$CDescuneto=$Precio*$Descuento/100;
$PVenta=$Precio-$CDescuneto;
else
?>
<html>
<body>
<center>Empresa Card</center>
</h2>
<h3>
<center>Venta de vehiculos</center>
</h3>
<table border="2">
<tr>
<th>Mazda 2000...(1)</th>
<th>Volvo 2010...(2)</th>
</tr>
<tr>
</tr>
<tr>
<div>
</td>
</tr>
</table>
<br />
<table border="2">
<tr>
<th>Datos</th>
</tr>
<tr>
Vasquez Contreras, Rafael Daniel Paá gina 9
Analista Programador
Email:Rafofoxbasic2000@hotmail.com
<th>Precio:<input type="text" name="TxtPrecio" value="<? echo $Precio; ?>"/></th>
</tr>
<tr>
</tr>
<tr>
</tr>
</table>
</form>
</body>
</html>