i'm PHP Programmer and i'm Here to Help PHP developers with php coding




Control structure condition statement(if,else if,else, switch case)example in PHP programming language


<html> <head> <title>Untitled Document</title> </head> <body>
<form method="get" action="<? $_SERVER["PHP_SELF"] ?>"/>
Your qualification: <input name="saje" type="radio" value="DEGREE" checked="checked" /> degree
<input name="saje" type="radio" value="MASTER" /> master Your salary
<select name="salary"> <option value="" selected="selected">please select</option> <option value="1">BELOW RM1000 </option> <option value="2">RM1000 TO RM2000</option> <option value="3">RM2000 TO RM3000</option> <option value="4">ABOVE RM3000</option> </select>
<input type="submit" value="PROCEEDAA">
</form>

<?
echo " ";
echo "KELULUSAN HANG:".$_REQUEST['saje'];
echo " ";
$salary = $_REQUEST['salary'];


if($salary=="1") { echo "gaji hang below RM1000"; }
else if($salary=="2") { echo "gaji hang antara RM1000 ke RM2000"; }
else if($salary=="3") { echo "gaji hang antara RM2000 ke RM3000"; }
else if($salary=="4") { echo "gaji hang atas RM4000"; }
else { echo "Hang tak pilih gaji";} echo " ";

switch($salary) {

case "1":
echo "gaji hang below RM1000";
break;

case "2":
echo "gaji hang antara RM1000 ke RM2000";
break;

case "3":
echo "gaji hang antara RM2000 ke RM3000";
break;

case "4":
echo "gaji hang atas RM4000";
break;

default: echo "Hang tak pilih gaji";
} ?>
</body> </html>


Read more...