I have used the below php code to retrieve the top 8 from an EmployeeTable (connection part I havenot included below as it is irrelevant ) :
$q4 = "select top 8 *
from EmployeeTable
order by LevelFieldTotal desc";
$stmt3=sqlsrv_query($conn,$q4);
if($stmt3==false)
{
echo 'error to retrieve info !! <br/>';
die(print_r(sqlsrv_errors(),TRUE));
}
$toprow2=sqlsrv_fetch_array($stmt3);
I want to echo the top 8 in this leaderboard : https://jsfiddle.net/o20n61eu/4/
I tried to echo it in the html ,but I am getting only the ist person among the toppers getting echoed.
How Can I echo in the leaderboard,such that I get to see all the top 8 persons in the leaderboard through the above php variable,which holds the top8 in it.
I donot want to do it individually for each person.I want to use the above query and fetch the top8 through only one query and echo it.
the part of the html,where I tried to echo the php variable :(its in the above fiddele link also)
<div id="overalllb" class="leadboardcontent" style="display:none">
<div class="leaderboard">
<ol>
<li>
<mark>
<?php echo "". $toprow2[ 'EmployeeName'] . ""?>
</mark>
<small><?php echo "". $toprow2['Total_points_Rewarded'] .""?></small>
</li>
<li>
<mark>Brandon Barnes1</mark>
<small>3101</small>
</li>
<li>
<mark>Raymond Knight1</mark>
<small>2192</small>
</li>
<li>
<mark>Trevor McCormick1</mark>
<small>2145</small>
</li>
<li>
<mark>Andrew Fox1</mark>
<small>2103</small>
</li>
<li>
<mark>And1rew Fox1</mark>
<small>2103</small>
</li>
<li>
<mark>Tre1vor McCormick1</mark>
<small>2145</small>
</li>
<li>
<mark>Andrew Fox1</mark>
<small>2103</small>
</li>
</ol>
</div>
</div>
solution as suggested by @Magnus and @Mayank
<div id="overalllb" class="leadboardcontent" style="display:none">
<div class="leaderboard">
<ol>
<li>
<mark>
<?php while( $toprow2=s qlsrv_fetch_array( $stmt3) ) { echo $toprow2[ 'overallRank'] . " ".$toprow2[ 'EmployeeName'] . " ".$toprow2[ 'Total_points_Rewarded']. "<br/>";} ?>
</mark>
</li>
</ol>
</div>
</div>
Kindly help.Thanks.God bless.
</div>