Contoh Form Output PHP If Else
<?
$kode=$HTTP_POST_VARS['kode'];
if ($kode=='NOK')
$merk="NOKIA";
else if ($kode=="SGH")
$merk="SAMSUNG";
ELSEif ($kode=="ERC")
$merk="SONY ERRICSON";
else
$merk="Merk Lain";
ECHO"<PRE>";
echo"Kode HP : $kode$type<br>";
echo"Type HP : $type<br>";
echo"Merk : $merk<br>";
echo"Harga : Rp.$harga<br>";
$total=$harga*$jumlah;
echo"Subtotal Bayar : Rp.$total<br>";
//IF ($jumlah>3)
// $disc=0.4*$total;
// ELSE IF ($jumlah>2)
// $disc=0.2*$total;
// ELSE
// $disc=0.1*$total;
SWITCH ($jumlah)
{
case 2:
$disc=0.02*$total;
break;
case 3:
$disc=0.05*$total;
break;
default:
$disc=0.1*$total;
}
echo"Discount : Rp.$disc<br>";
$totalbyr=$total-$disc;
echo"Harga Yang Harus di bayar : Rp.$totalbyr";
echo"<form action=if_else.php method=post><input type=submit
value=Kembali></form>";
?>