I have 4 input fields. One is ID.. and the three other are 3 subjects. When I enter an ID, I have to input 3 corresponding marks for each subjects. When a mark greater than 100 is entered irrespective of the ID entered, the script should display in ascending order the ID entered previously which are less or equal to 100. Please help me to achieve that in php.
<form action = "index.php" method ="POST">
Student ID:<br>
<input type = "text" name = "id"><br><br>
Mark for Module 1:<br>
<input type = "text" name = "marks1"><br><br>
Mark for Module 2:<br>
<input type = "text" name = "marks2"><br><br>
Mark for Module 3:<br>
<input type = "text" name = "marks3"><br><br>
<input type = "submit" value = "Submit">
</form>
<?php
session_start();
if(isset($_POST['id']) && isset($_POST['marks1']) && isset($_POST['marks2']) && isset($_POST['marks3'])){
if ($_POST['marks1'] && <=100 && $_POST['marks2'] <= 100 && $_POST['marks3'] <= 100){
$_SESSION['info'][] = array($_POST['id'] => array(
"Module 1" => $_POST['marks1'],
"Module 2" => $_POST['marks2'],
"Module 3" => $_POST['marks3']
)
);
}elseif (isset($_SESSION['info'])) {
$marks = array();
foreach($_SESSION['info'] as $key =>$values){
foreach($values as $name=>$mark){
$marks[$key] = $mark;
}
}
Aucun commentaire:
Enregistrer un commentaire