Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone help me with these warnings? Code Below. //HW_Form_3.php <h1>Michael

ID: 3805203 • Letter: C

Question

Can someone help me with these warnings? Code Below.

//HW_Form_3.php

<h1>Michael McCann Hw 3</h1>

<h2>Student Grades</h2>
<form method="post" action="HW_Process_3.php">
<table>


<html>
<head>
<title></title>
</head>
<body>
<?php
$hw3data_handle = fopen("hw3data.txt", "r");
$hw3data_array = array();
if($hw3data_handle) {
while(($line = fgets($hw3data_handle)) != false) {
array_push($hw3data_array, explode(" ", $line));
}
}
echo "<form action = 'hw3_process.php' method = 'POST'>";
echo "<table align = 'left'>";
echo "<tr><th>Student Name</th><th>Student ID</th><th>Grade</th></tr>";
$grade_combo = "<option value = 'None'>None</option>
<option value = 'A+'>A+</option>
<option value = 'A'>A</option>
<option value = 'A-'>A-</option>
<option value = 'B+'>B+</option>
<option value = 'B'>B</option>
<option value = 'B-'>B-</option>
<option value = 'C+'>C+</option>
<option value = 'C'>C</option>
<option value = 'C-'>C-</option>
<option value = 'D+'>D+</option>
<option value = 'D'>D</option>
<option value = 'D-'>D-</option>
<option value = 'F'>F</option>";
foreach($hw3data_array as $student) {
echo "<tr><td>" . $student[0] . ", " . $student[1] . "</td><td>" . $student[2] . "</td><td>" . "<select name = '" . $student[0] . "_" . $student[1] . "_grade' id = '" . $student[0] . "_" . $student[1] . "_grade' size = '1'>" . $grade_combo . "</select></td></tr>";
}
echo "<tr><td><input type = 'submit' name = 'Submit' align = 'center'/></td>";
echo "<td><input type = 'reset' name = 'Reset' align = 'center'/></td></tr>";
echo "</table>";
echo "</form>";
?>
</body>
</html>

</form>

//HW_Process_3.php

<?php
if(isset($_SESSION['data_array'])) {
$students_data = $_SESSION['data_array'];
}

echo "<table align = 'left'>";
echo "<tr><th>Student Name</th><th>Student ID</th><th>Grade</th></tr>";
foreach($students_data as $student) {
echo "<tr><td>" . $student[0] . ", " . $student[1] . "</td><td>" . $student[1] . "</td><td>" . $_POST[$student[0] . "_" . $student[1] . "_grade"] . "</td></tr>";
array_pushs($student, $_POST[$student[0] . "_" . $student[1] . "_grade"]);
}
  
echo "</table>";
$grade_count = array("A+" => 0, "A" => 0, "A-" => 0, "B+" => 0, "B" => 0, "B-" => 0, "C+" => 0, "C" => 0, "C-" => 0, "D+" => 0, "D" => 0, "D-" => 0, "F" => 0, "None" => 0);
foreach($students_data as $student) {
$grade_count[$_POST[$student[0] . "_" . $student[1] . "_grade"]] += 1;
}
echo "<br /><br />";
echo "<table align = 'left' />";
echo "<tr><th>Grade</th><th>Count</th></tr>";
foreach($grade_count as $grade => $count) {
echo "<tr><td>" . $grade . "</td><td>" . $count . "</td></tr>";
}
echo "</table>";
?>
</body>
</html>

Student Name Student ID Grade Notice: Undefined variable: students data in C:lwamp64lwwwillHW Process 3.php on line 8 Call Stack Time Memory Location Function 263176 main O 0.0028 HW Process 3.php:0 warning: Invalid argument supplied for foreacho in C:wamp64hwww 11Hw Process 3.php on line s Call Stack Time Memory Function Location O HW Process 3php:0 263176 main 0.0028 Notice: Undefined variable: students data in C:lwamp64lwwwillHW Process 3.php on line 15 Call Stack Time Memory Location Function 263176 main O 0.0028 HW Process 3.php:0 Warning: Invalid argument supplied for foreach0 in C:wamp64lwwwlil HW Process 3.php on line 15 Call Stack Time Memory Function Location HW 1 0 0028 263176 (main) Process 3.php:0

Explanation / Answer

please upload your text file too

There is a problem with the session array

$students_data is given inside if as well as there is no value in your session array. To know that please print and check wether your session array has value or empty.To know that just add the code print_r($_SESSION['data_array']);

exit.

please upload your full code including text file so that i can help you

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote