Monday 12 September 2016

How to used php(using for loop) in switch case

How to used php(using  for loop) in switch case;



<input type="text" name="c"/>

<input type="submit" name="btn"/>
<select name="c">
<option value="green">Green</option>
</select>


<?php

if(isset($_POST['btn'])) {?>
<?php
 $color =$_POST['c'];
switch('$color') {
case 'red':
echo 'on';
break;
case 'green':
echo 'off';
break;
default:
echo 'none';
}
?>

No comments:

Post a Comment