Question

This code should be written in php. Write a program that allows the user to input...

This code should be written in php.

Write a program that allows the user to input a student's last name, along with that student's grades in English, History, Math, Science, and Geography.

When the user submits this information, store it in an associative array, like this:
Smith=61 67 75 80 72
where the key is the student's last name, and the grades are combined into a single space-delimited string.

Return the user back to the data entry screen, to allow more student names and grades to be entered.

When the user has completed grade entry for all students, allow him/her to generate a grade report. This report should output a table to the screen with a row for each user, and a column for each grade. Failing grades (less than 60) should be printed in red.

Hint: When creating the report, loop through the associative array. Use the split() function to parse the grade string for each student into its own temporary array, that can be looped through to output that student's grades.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Explanation :

The Index File allows the user to enter the Values and gives the values to test.php File. Now, the Grade Report is generated and the Conditions are satisfied here.


Code :

index.html file :

<!DOCTYPE HTML>
<html>
   <body>
       <form action="test.php" method="POST">
           Enter Last Name : <input type="text" name="lname"><br>
           English Marks : <input type="text" name="eng"><br>
           History Marks : <input type="text" name="hist"><br>
           Math Marks : <input type="text" name="math"><br>
           Science Marks : <input type="text" name="sci"><br>
           Geography Marks : <input type="text" name="geo"><br>
           <input type="submit">
       </form>
   </body>
</html>

test.php file :

<!DOCTYPE html>
<html>
   <head>
       <style>
       table {
       font-family: arial, sans-serif;
       border-collapse: collapse;
       width: 100%;
       }

       td, th {
       border: 1px solid #dddddd;
       text-align: left;
       padding: 8px;
       }
       </style>
   </head>
   <body>

       <h1>Grade Report</h1>

       <?php
           function getProperColor($var)
           {
           if ($var < 60)   return '#FF0000';
           else return '#FFFFFF';
           }      
       ?>

       <table>
       <tr>
       <th>Last Name</th>
       <th>English</th>
       <th>History</th>
       <th>Mathematics</th>
       <th>Science</th>
       <th>Geography</th>
       </tr>
       <tr>
       <td><?php echo $_POST["lname"];?></td>
       <td style="background-color: <?php $color = getProperColor($_POST['eng']); echo $color; ?>"> <?php echo $_POST["eng"];?></td>
       <td style="background-color: <?php $color = getProperColor($_POST['hist']); echo $color; ?>"> <?php echo $_POST["hist"];?></td>
       <td style="background-color: <?php $color = getProperColor($_POST['math']); echo $color; ?>"> <?php echo $_POST["math"];?></td>
       <td style="background-color: <?php $color = getProperColor($_POST['sci']); echo $color; ?>"> <?php echo $_POST["sci"];?></td>
       <td style="background-color: <?php $color = getProperColor($_POST['geo']); echo $color; ?>"> <?php echo $_POST["geo"];?></td>
       </tr>
       </table>
   </body>
</html>

Add a comment
Know the answer?
Add Answer to:
This code should be written in php. Write a program that allows the user to input...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For C++ program Your program should first prompt the user for the number of students they...

    For C++ program Your program should first prompt the user for the number of students they wish to enter. For each student, the user will be prompted to enter the student’s name, how many tests the student has taken, and the grade for each test. Each test’s grade will be inputted as a number representing the grade for that test. Once each student’s information has been entered, the program will display the number of students. Additionally, each student will have...

  • using C# Write a program which calculates student grades for multiple assignments as well as the...

    using C# Write a program which calculates student grades for multiple assignments as well as the per-assignment average. The user should first input the total number of assignments. Then, the user should enter the name of a student as well as a grade for each assignment. After entering the student the user should be asked to enter "Y" if there are more students to enter or "N" if there is not ("N" by default). The user should be able to...

  • in c++ A: Write a program which ask user to enter 10 student's name and their...

    in c++ A: Write a program which ask user to enter 10 student's name and their grades. Then find the average of all the grades. Output all the grades with student name of whom got the grade over the average.

  • In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a tes...

    In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a test grade (integer value) for each student in a class. Validation Tests are graded on a 100 point scale with a 5 point bonus question. So a valid grade should be 0 through 105, inclusive. Processing Your program should work for any...

  • Write a C program that allows a user to enter up to 30 student id’s and...

    Write a C program that allows a user to enter up to 30 student id’s and 3 grades per student. It will then compute and display a report of the students averages, and then a statement of the class average for those grades. The following is a sample run that demonstrates what your program should look like: Please enter your school name: Cape Tech Welcome to the Cape Tech Grade Calculator Enter the number of students to process (0 -...

  • Need a PHP code that has a box to type in that allows the user to...

    Need a PHP code that has a box to type in that allows the user to put the information through the PHP site to the database for the following categories: INT, First name, Last name, Sex. Once injected it needs to echo to the page to show the table of all entries. The code below is how far I got with it. MySQL: add a row and query $link = mysql_connect('stewcraw.dotstermysql.com', 'prof', '3632password'); if (!$link) { die('Could not connect: '...

  • PYTHON PROGRAMMING Instructions: You are responsible for writing a program that allows a user to do...

    PYTHON PROGRAMMING Instructions: You are responsible for writing a program that allows a user to do one of five things at a time: 1. Add students to database. • There should be no duplicate students. If student already exists, do not add the data again; print a message informing student already exists in database. • Enter name, age, and address. 2. Search for students in the database by name. • User enters student name to search • Show student name,...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • Write a web program to allow the user to sort a list of things. Use HTML...

    Write a web program to allow the user to sort a list of things. Use HTML and PHP. Your input (HTML) should include a text area the user can type in their list. The output (PHP) should be in the form of a table. Use the explode command to break the input up into an array. $list=explode(PHP_EOL, $stuff); Once you have the text into an array, use the sort function to sort it, and then loop through it and print...

  • Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and...

    Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and his/her course names with grades. ? Your system should allow the user to input, update, delete, list and search students’ grades. ? Each student has a name (assuming no students share the same name) and some course/grade pairs. If an existing name detected, user can choose to quit or to add new courses to that student. ? Each student has 1 to 5 courses,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT