Question: 4. Create the a9view.php file based on the view_users.php file used in Ch 09. Save the a9view.php file in the following path on your webserver:

4. Create the a9view.php file based on the view_users.php file used in Ch 09. Save the a9view.php file in the following path on your webserver: htdocs/Ch09/. Requirements are as follows:

a. Your a9view.php file should have a page title that reads View the Champs.

b. The include should point to the a9header.html file.

c. The Page Header h1 should read MLB Champs.

d. The require should require the a9mysqli_connect.php. Be careful about the path. If your a9mysqli_connect.php file is in the same directory as the a9view.php file, remove the ../ in the require statement from the view_users.php file or you will get a fatal error.

e. Revise the query to pick up the team, teamid, pennants, and worldseries columns from the champs table. Remember that each of these must be saved AS something as exemplified in the $q= statement used in the view_users.php file. Later whatever you save them AS will be referred to when printing the resulting table. (2 points) f. Instead of printing the number of users, print the number of baseball teams in the champs table.

g. Edit the table header to include 4 columns: Team, Team ID, Pennants, World Series. Left Align the team and right align theTeam ID, Pennants, and World Series columns.

h. Fetch and print all the records for the Team, Team Id, Pennants, and WorldSeries as the table rows. Please recall whatever you save these pieces of data AS in Step e. will need to be referred to here.

i. Close the table, free up the resources.

j. Edit the error message used if no records are returned to read There are currently no baseball teams in the database.

k. Close the database connection.

l. Include the footer.html file.

----------------------------I have most of the code but I have an error message when i try and open it that says:

Notice: Undefined variable: dbc in C:\xampp\htdocs\BaseballV3\a9view.php on line 38

Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\BaseballV3\a9view.php on line 38------------------------

The code I have is:

$page_title = 'View the Champs';

include ('a9header.html');

echo '

MLB Champs

';

//if ($_SERVER['REQUEST_METHOD'] == 'POST') {require ('a9mysqli_connect.php');}//if I remove the (if statement) and put the only required ... none of the echos will print in the browser.

//all three select statements work when I use them in the terminal.

/*$query = "SELECT

t.team AS T,

t.team_id AS Ti,

c.pennants AS P,

c.worldseries AS W

FROM

`teamsets` AS t

LEFT JOIN

`champs` AS c ON t.team_id = c.team_id

WHERE

ISNULL(c.team_id) = FALSE"

;

//////////

//$query = "SELECT t.team AS T, t.team_id AS Ti, c.pennants AS P, c.worldseries AS W from `teamsets` as t join `champs` as c on t.team_id = c.team_id;";

*/

//selecting info...

$query = "

SELECT t.team AS T

, t.team_id AS Ti

, c.pennants AS P

, c.worldseries AS W

from teamsets as t

join champs as c

on t.team_id = c.team_id;

";

$result = mysqli_query ($dbc, $query); //I removed the @ so I can see the warning in the browser.

if ($result) {

// Count the number of returned rows:

$num = mysqli_num_rows($result);

//Create an HTML table for displaying the query results:

if ($num > 0) { // If it ran OK, display the records.

echo "

There are currently $num baseball teams.

";

echo '

;

'

;

//Fetch and print each returned record:

while ($row = mysqli_fetch_array ($result, MYSQLI_ASSOC)) {

echo '

';

}

echo '

Team Team ID Pennants WorldSeries
' . $row['T'] . '' . $row['Ti'] . '' . $row['P'] . '' . $row['W'] . '
';

mysqli_free_result ($result);

}

else { //If it didnot run OK.

// Public message:

echo '

There are currently no baseball teams in

the database.

';

echo '

' . mysqli_error($dbc) . '

Query: ' . $query . '

';

}

mysqli_close($dbc); }// Close the database connection.

include ('a9footer.html');

?>

--------------------------------------------------------------------------------------------

5. Create the a9update.php file based on the password.php file used in Ch09. Save the a9update.php file in the following path on your webserver: htdocs/Ch09/. Requirements are as follows:

a. Your a9update.php file should have a page title that reads Update thePennants and World Series. (2 points)

b. Include the a9header.html file.

c. Check for for submission.

d. Require the a9mysqli_connect.php file.

e. If the Team Id is not entered on the HTML form, ensure that a message You forgot to enter the Team ID. Is displayed to the user.

f. If the Team is not entered on the HTML form, ensure that a message You forgot to enter the Team is displayed to the user.

g. If the number of Pennants Won is not entered on the HTML form, ensure that a message You forgot to enter the Pennants to be updated is displayed to the user.

h. If the number of World Series Won is not entered on the HTML form, ensure that a message You forgot to enter the World Series to be updated is updated to the user. i. Check to see if the errors array is empty.

j. If so, check to see if a valid Team Id and Team has been entered and proceed with the necessary code to update the champs table with the Pennants and World Series. Display a message to the user that The Pennants and World Series have been updated!.

k. If the query did not run OK, display a message to the user that says System Error The Pennants and World Series could not be changed due to a system error. We apologize for any inconvenience. Provide a debugging message to the programmer displaying the query that went wrong.

l. If the valid Team ID and Team combination was not entered correctly, be sure to display a message: The team id and team name combination does not match any on file. Please view the teams again to see the correct team id and team names to use.

m. Close the database connection.

n. Include the footer.html file.

o. Test the operation of the a9update.php file by updating the following records: New York Yankees who have won 40 Pennants and 27 World Series. San Francisco Giants who have won 22 Pennants and 7 World Series. St. Louis Cardinals who have won 22 Pennants and 11 World Series. Then click on View Champs to run the a9view.php file to view the newly updated Champs table.

Please help me

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!