Howdy I’m looking for some help / start with this as I cant seem to get it going.
I want to build a leaderboard that pulls results from a mysql database. There are 4 columns FIRST, SECOND, THIRD and FOURTH and each column contains the names of the people who won that place. Also there will be duplicate names across each of the columns.
I plan to assign points to each column too, so column FIRST =100pts and column SECOND = 75pts etc.
I run the query to get all the data.
[php]$query = mysqli_query($con,“SELECT FIRST, SECOND, THIRD, FOURTH FROM results”);[/php]
So then I’m not really sure the best way to tackle it.
I am trying this
[php]while($row = mysqli_fetch_array($query))
{
$firstarr[] = $row[‘FIRST’];
$secondarr[] = $row[‘SECOND’];
$thirdarr[] = $row[‘THIRD’];
$fourtharr[] = $row[‘FOURTH’];
}[/php]
So my thinking here is I have I have all names including duplicates saved to arrays so I can count them to do the multiplication sum for the points later.
[php]while($row = mysqli_fetch_array($query))
{
$firstarr[] = $row[‘FIRST’];
$secondarr[] = $row[‘SECOND’];
$thirdarr[] = $row[‘THIRD’];
$fourtharr[] = $row[‘FOURTH’];
}
$result1 = array_unique($firstarr);
$result2 = array_unique($secondarr);
$result3 = array_unique($thirdarr);
$result4 = array_unique($fourtharr);
$arrcount1 = array_count_values($firstarr);
$arrcount2 = array_count_values($secondarr);
$arrcount3 = array_count_values($thirdarr);
$arrcount4 = array_count_values($fourtharr);[/php]
So here is where I’m stumped…I have all the names and how many times any names are unique to each column across the table. But I have 8 arrays 4 with names and 4 with the counts and not sure where to proceed…