How can I make it show all the usernames and the amount they carry? so far only the first user returns and the others do not ...
<?php
ini_set('display_errors', 1); error_reporting(E_ALL);
$ayer = new DateTime(''.date('Y-m-d', strtotime('last day')).'');
$ayer = $ayer->getTimestamp();
$hoy = new DateTime(date('Y-m-d'));
$hoy = $hoy->getTimestamp();
$link = new PDO('mysql:host=localhost;dbname=db', 'root', '12345678');
foreach ($link->query('SELECT * from members') as $row) {
$id_de_usuario= "". $row['id']. "\n";
$username= ''. $row['username']. "\n";
foreach ($link->query("SELECT COUNT(*) total FROM ptsu_requests WHERE status='Completed' AND date>=$ayer AND date<=$hoy AND user_id=" . $id_de_usuario) as $row) {
$fila1 = '' . $row['total'] . "</br>";
echo $fila1;
function setRankings($standings) {
$rankings = array();
arsort($standings);
$rank = 1;
$tie_rank = 0;
$prev_score = -1;
foreach ($standings as $name => $score) {
if ($score != $prev_score) { //this score is not a tie
$count = 0;
$prev_score = $score;
$rankings[$name] = array('score' => $score, 'rank' => $rank);
} else { //this score is a tie
$prev_score = $score;
if ($count++ == 0) {
$tie_rank = $rank - 1;
}
$rankings[$name] = array('score' => $score, 'rank' => $tie_rank);
}
$rank++;
}
return $rankings;
}
//===================================================
//test the above function
$scores = array(
$username => $fila1
);
$rankedScores = setRankings($scores);
//display the player rankings
foreach ($rankedScores as $player => $data) {
echo $player . ' - ' . $data['score'] . ' - ' . $data['rank'] . '<br />';
}
}
}
?>