Based on the score of each team, determine the winner, loser, or drawer. Add appropriate points to each team Hint 3: now you have an array of teams with all the needed information, just create 2 comparison functions and use the sort function to sort the teams. Hint 4: use fgetcsv() to read each row; use explode() to extract the score of each team.

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter11: Sql Server Databases
Section: Chapter Questions
Problem 15RQ
icon
Related questions
Question

Create a php file for this task. Depending on whether "Top Scorers" or "Leaders" has been clicked, you need to display the top 10 teams sorted by their total scores or total points earned. You have to read the whole CSV file when calculating total scores and total points.

Top Scorers

Display a table with two columns: Team and Scores. The team that has the highest number of scores is displayed first. You have to display the top 10 teams only.

Note: in the CSV file, for the first row, you will see something like

Arsenal FC,4-3,Leicester City FC

that means for this particular match, Arsenal FC scored 4 and Leicester City FC scored 3. This rule applies to all other rows as well. For this "Top Scorers" display, you need to calculate the total score of every team and then display the top 10 teams.

Leaders

Display a table with two columns: Team and Points. The team that has the highest number of points is displayed first. You have to display the top 10 teams only.

Note: in the CSV file, for the first row, you will see something like

Arsenal FC,4-3,Leicester City FC

that means for this particular match, Arsenal FC scored 4 and Leicester City FC scored 3, so Arsenal FC wins this match. For a match, the winner earns 3 points, the loser earns zero points. If the match is a draw, both teams earn 1 point. This rule applies to all other rows as well. For this "Leaders" display, you need to calculate the total point of every team and then display the top 10 teams.

https://raw.githubusercontent.com/TriDang/cosc2430-2022-s2/main/data/football.csv

Hint 1: maintain an associative array like this

[

'team 1 name' => ['scores' => calculated_score, 'points' => 'calculated points'],

'team 2 name' => ['scores' => calculated_score, 'points' => 'calculated points'],

'team 3 name' => ['scores' => calculated_score, 'points' => 'calculated points']

]

In other words, use team names as the keys for the array. The value of each key is itself another array

Hint 2: loop through the CSV file

If the team name has not existed yet => add a new array element and assign calculated scores and calculated points as zeros.

Extract the FT column to get the score of each team. Add the score to each team

Based on the score of each team, determine the winner, loser, or drawer. Add appropriate points to each team

Hint 3: now you have an array of teams with all the needed information, just create 2 comparison functions and use the sort function to sort the teams.

Hint 4: use fgetcsv() to read each row; use explode() to extract the score of each team.

Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Hash Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning