I’m new to php and am confused as to how to make input boxes that have the same name ONE array, I tried putting brackets after the name but to no avail. [URL=”http://userpages.umbc.edu/~ofek1/gpa.html”]http://userpages.umbc.edu/~ofek1/gpa.html
report.php:
[CODE]<html>
<head>
</head>
<body>
<?php
$credits = $_POST[‘credits’];
$points = $_POST[‘points’];
$semester = $_POST[‘sem’];
/****************************************************************************
** TotalPoints – Totals the number of quality points earned
** Input – None
** Output – Total quality points earned
****************************************************************************/
function TotalPoints()
{
$numCredits = $credits;
$numPoints = $points;
$totalPoints = 0;
for ($i = 0; $i < count($numCredits); $i++)
{
$totalPoints = $totalPoints + ($numCredits[i] * $numPoints[i]);
}
echo $totalPoints;
}
/****************************************************************************
** TotalCredits – Totals the number of credits taken
** Input – None
** Output – Total credits taken
****************************************************************************/
function TotalCredits()
{
$numCredits = $credits;
$numPoints = $points;
$totalCredits = 0;
for ($i = 0; $i < count($numCredits); $i++)
{
$totalCredits = $totalCredits + $numCredits[i];
}
echo $totalCredits;
}
/****************************************************************************
** CalculateGPA – Divides total quality points by number of credits taken
** Input – None
** Output – Calculated GPA
****************************************************************************/
function CalculateGPA()
{
$finalGPA = TotalPoints() / TotalCredits();
$finalGPA = floatval($finalGPA);
echo $finalGPA;
}
/****************************************************************************
** GenerateGradeReport – Displays the grade report to the user
** Input – Semester
** Output – None
****************************************************************************/
function GenerateGradeReport($semester)
{
$finalGPA = CalculateGPA();
$totalCredits = TotalCredits();
$totalPoints = TotalPoints();
echo “GPA report for ” . $semester . “<br /><br />”;
echo “Credits taken: ” . $totalCredits . “<br /><br />”;
echo “Quality points earned: ” . $totalPoints . “<br /><br />”;
echo “GPA for ” . $semester . “: ” . number_format($finalGPA, 3) . “<br /><br />”;
}
GenerateGradeReport($semester);
?>
</body>
</html>