How would I input the same randomized values 27 times into that array $data?
It outputs a correctly formatted table with one row of randomized values, now just need to redo these values 27 times.
The array is two dimensional would that makes things harder?
Any and all help is appreciated very much I am just a beginner.
<html>
<STYLE type="text/css">
td{
border-left: 1px solid #f09d09;
}
th{
border: 1px solid #f09d09;
}
</STYLE>
<body>
<table>
<tr>
<th>Number</th>
<th>Student Number</th>
<th>Coursework Mark</th>
<th>Exam Mark</th>
<th>Module Mark</th>
<th>Module Result</th>
<th>Comments</th>
</tr>
<?php
$examPassmark = 40; //Hardcoded exam pass mark
$courseworkPassmark = 40; // Hardcoded coursework passmark
$n = rand(1,27);
$sn = "B00" . rand(200000,599999); //randomised student number with the prefix B00 e.g B00-299999
$cwm = rand(25,100); //randomised coursework mark
$em = rand(25,100); // randomised exam mark
$mm = round(((($cwm / 200) * 20) + (($em / 200) * 80) * 2)) ; //exam weighting is cw/e = 20/80
$mr = 'Fail';
$stack = array("");
if($em > $examPassmark && $cwm > $courseworkPassmark) //This if statement states that ONLY if both Coursework and the exam are passed will a student pass the module
{
$mr = 'Pass';
}else{
$mr = 'Fail';
}
if($cwm < $courseworkPassmark) //Checks to see if the student passed coursework
{
$com = 'Resit CourseWork';
}
else if($em < $examPassmark) // Checks to see if the student passed the exam
{
$com = 'Resit Exam';
}else{
$com = 'None'; //outputted if both are passed
}
for($i = 0; $i <= 27; $i++)
{
$data = array( array($n, $sn, $cwm, $em, $mm, $mr, $com) //Here we have an two dimensional array that will be filled with the values created above
);
$data[$i] .= $stack;
}
for ($row = 0; $row < 27; $row++) //rows (I use 8 to give each column padding so it isnt squeezed together)
{
for ($col = 0; $col < 7; $col++) //columns output to the number of entries in the array $data
{
echo "<td>".$data[$row][$col]."</td>"; //within each column print out the value held within $data
}
}
echo '</table>'; //end the table
?>
</body>