Re: Associative Array Disappears Inside Program
| From: | Guru Geek | Date: | Wed, 30 Apr 2003 15:49:42 +0000 |
| Subject: | Re: Associative Array Disappears Inside Program | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-145799@lists.php.net to get a copy of this message | ||
Sorry bout that. I was trying to keep the post to a minimum. Didn't want
to aggrevate anyone by creating a huge email. The program is obviously a
fall through logic program. So step three is at the top and step one is at
the bottom.
Hope I'm not dating myself with the flowerboxes. If anyone remembers
when/where those came from ;-)
<?php
//######################
//# SETTING VARIABLES #
//######################
$dir = "/gpa/";
//###############################
//# WORK WITH VALUES step three#
//###############################
if ($submitValues) {
include ($dir."gpaheader.php");
for ($mathCount=0; $mathCount < count($creditBox); $mathCount++)
{
$points = 4 * $creditBox[$mathCount];
$totalPoints = $totalPoints + $points;
$divider = $divider + $creditBox[$mathCount];
$lineSum = $creditBox[$mathCount] * $estimatedGrade[$mathCount];
$primalCount = $primalCount + $lineSum;
}
$ghostGpa = $primalCount / $divider;
echo "You are taking a total of $divider credit hours.<br>";
echo "You have $totalPoints points possible.<br>";
echo "You scored $primalCount points.<p>";
echo "Your $primalCount points divided by the $divider credit hours gives
you a GPA of $ghostGpa";
echo "<p>";
$database_array[creditHoursTaken]= $divider;
$database_array[pointsPossible]= $totalPoints;
$database_array[earnedPoints]= $primalCount;
$database_array[dreamGPA]= $ghostGpa;
echo "courses: $database_array[courses]<br>";
echo "hours taken: $database_array[creditHoursTaken]<br>";
echo "possible points: $database_array[pointsPossible]<br>";
echo "earned points: $database_array[earnedPoints]<br>";
echo "suggested gpa: $database_array[dreamGPA]";
include ($dir."gpafooter.php");
exit;
}
//#####################################
//# GET VALUES FOR COURSES step two#
//####################################
if ($submitCourses) {
$database_array[courses] = $numberCourses;
include ($dir."gpaheader.php");
for ($rayCount=0; $rayCount < $database_array[courses]; $rayCount++)
{
$hope[] = "placeHolder";
}
if (($database_array[courses] <= 100) && ($database_array[courses] >= 1))
{
echo '
<form method="post" action="gpa5.php">
<table border="2">
<tr>
<td> </td><td align="center">Credit Hours<br><font
size="-2">(1-5)</font></td><td align="center">Estimated
Grade
Points<br><font size="-2">(A=4, B=3, C=2, D=1, F=0)</font></td>
</tr>';
for ($boxCreator=0; $boxCreator < $database_array[courses];
$boxCreator++)
{
echo "
<tr>
<td align='center'>Course #$boxCreator</td>
<td align='center'><input type='text' name='creditBox[]'
size='2'></td>
<td align='center'><input type='text'
name='estimatedGrade[]'
size='2'></td>
</tr>";
}
echo '
<tr>
<td colspan="3" align="center">
<input type="submit" name="submitValues"
value="Continue"></td></tr>
</table></form>';
} else {
echo '
You have entered an invalid amount.<br>
You must enter a number between 1 and 100.<br>
Please try again.<br>
Click <a href="http://www.g-i-w-s.com/gpa/gpa5.php">HERE</a>
to
continue.';
}
include ($dir."gpafooter.php");
exit;
}
//####################################
//# GET NUMBER OF COURSES step one#
//###################################
include ($dir."gpaheader.php");
echo '
<form method="post" action="gpa5.php">
<table>
<tr>
<td align="right">How Many Courses Are You Taking:</td><td><input
type="text" name="numberCourses" size="2"></td></tr>
<tr>
<td><input type="submit" name="submitCourses"
value="Continue"></td></tr>
</table>
</form>';
include ($dir."gpafooter.php");
exit;
?>