Write PHP program to select list of subjects from list box and display selected subject on information. (Use sticky multi-valued parameter)||EasyCoding45

 In this Tutorial, we are Going to learn how we can Write a PHP program to select list of subjects from list box and display selected subject on information. (by Using sticky multi-valued parameter)


Program :-(save as .php extension)


<html>

<title>List of Subject</title>

<body>

<form method=get action="">

Select Subject :<br>

<input type=checkbox name=c1[] value=c <?php if(in_array('c',$_GET['c1'])) echo "checked";?>>C<br>

<input type=checkbox name=c1[] value=c++ <?php if(in_array('c++',$_GET['c1'])) echo "checked";?>>C++<br>

<input type=checkbox name=c1[] value=java <?php if(in_array('java',$_GET['c1'])) echo "checked";?>>JAVA<br>

<input type=checkbox name=c1[] value=php <?php if(in_array('php',$_GET['c1'])) echo "checked";?>>PHP<br>

<input type=checkbox name=c1[] value="data structure" <?php if(in_array('ds',$_GET['c1'])) echo "checked";?>>DATA STRUCTURE<br>

<input type=submit name=s value=Submit><br>

</form>

</body>

</html>

<?php

if(array_key_exists('s',$_GET))

{

$sub=join('  ',$_GET['c1']);

echo "You Selected: <br>$sub<br>";

}

?>



OutPut :-


                                    

Comments