Hi I’m trying to complete a task where I have produce a table with stats about past super bowl winners and losers. I am retrieving data from a table I have created
Example of data:
1 task is to produce a table to show how many time each team have won.
To do this I wanted to create a loop where I keep adding to an array. I will then output the array into a table
Code:
<?php
$aid = 10;
//below are the exact columns in posts table
$query = "SELECT * FROM codetable WHERE codeid = 3";
$select_products = mysqli_query($connection, $query);
while($row = mysqli_fetch_array($select_products)){
$year = $row['data1'];
$team_won = $row['data2'];
$team_lost = $row['data3'];
$win_points = $row['data4'];
$lose_points = $row['data5'];
$a1[] = array( $year, $team_won, $team_lost, $win_points, $lose_points );
$team_win[] = $team_won;
$team_lose[] = $team_lost;
}
$winners = array_values(array_unique($team_win)); //make winners list unique
$losers = array_values(array_unique($team_lose)); // make losers list unique
$joint = array_merge($team_win, $team_lose); // merge winners and losers list
$unq_joint = array_values(array_unique($joint)); // make the merged list unique
$x= 0;
// Create new array to place distinct values in
while($x < count($unq_joint)){
$a2[] = $unq_joint[$x];
$x++;
}
In the array $a2 I’d like to create an array with multiple columns in which I can populate in a while loop. The first column will be the name of the distinct teams, and I’d like the next column to be a count for the how many time a team has won a final.
Is it possible for me to do this.