As seen from the code below, I have created an array ($criteria) and out of that array created the headings ($heading) to match the fields in my database.
I am trying to pass the hidden value ($heading) using the name=criteria (see code below)
$criteria = array("Independence","Participation","Self Management","Computer Science","Digital Literacy","ICT");
$arrayLength = count($criteria);
echo "<form><table>";
for($count=0;$count<$arrayLength;$count++){
if($criteria[$count] == 'ICT'){
$heading = strtolower($criteria[$count]);
}else{
$heading = lcfirst(str_replace(' ','',$criteria[$count]));
}
echo " <tr><td>$criteria[$count]</td></tr>
<tr><td>Current Rating: $row[$heading]</tr></td>
<input type=hidden name=criteria value=$heading>
<tr><td> ". $this->createRatingButtons() ."</td></tr>
<tr><td></td></tr><tr><td></td></tr>";
}
echo "
<input type=hidden name=student value=$student>
<input type=hidden name=unit value=$unit>
<input type=hidden name=formGroup value=$formGroup>
</form></table>";
Looks like this –
Independence
Current Rating: 1
Separate buttons labelled (1, 2, 3, 4, 5) appear here
Participation
Current Rating: 0
Separate buttons labelled (1, 2, 3, 4, 5) appear here
Self Management
Current Rating: 0
Separate buttons labelled (1, 2, 3, 4, 5) appear here
Computer Science
Current Rating: 0
Separate buttons labelled (1, 2, 3, 4, 5) appear here
Digital Literacy
Current Rating: 0
Separate buttons labelled (1, 2, 3, 4, 5) appear here
ICT
Current Rating: 0
Separate buttons labelled (1, 2, 3, 4, 5) appear here
Buttons are created using the function below, which is called as seen in the code above.
public function createRatingButtons(){
$result = "";
for($count=1;$count<=6;$count++){
$result.= "<input type=submit name=rating value=$count> ";
}
return $result;
}
PROBLEM – When I click the button e.g. under Participation criteria, I press button no. 2, then I can pass the hidden value rating=2 (works fine as seen from the code above), but I also want the criteria for which the rating button was pressed, in this case criteria=participation – but it sends the following –
http://localhost/marking/index.php?criteria=independence&criteria=participation&rating=2&criteria=selfManagement&criteria=computerScience&criteria=digitalLiteracy&criteria=ict&student=Liam&unit=Flowol&formGroup=7.8
As seen in the link above criteria=independence and criteria=selfManagement etc are all passed! I only want that criteria=participation should be passed as I clicked the button 2 under participation criteria.
Tags: ph