Gegevens uit Array
Hoi,
Ik wil graag uit een Array alleen de eerste 5 waardes opvragen. Ik heb nu de volgende code, maar dit geeft dus de volledige lijst. Weet iemand hoe ik alleen de eerste 5 hieruit haal?
Ik wil graag uit een Array alleen de eerste 5 waardes opvragen. Ik heb nu de volgende code, maar dit geeft dus de volledige lijst. Weet iemand hoe ik alleen de eerste 5 hieruit haal?
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
$queryp = "SELECT spelernaam, SUM(totaal) AS totaal FROM rondes GROUP BY spelernaam ORDER BY totaal DESC";
$resultp = mysql_query($queryp);
$nump = mysql_num_rows($resultp);
while ($row = mysql_fetch_array ($resultp)) {
echo '<table width="100%">
<tr>
<td width="50%">
<a href="../spelersinfo/puntenperspeler.php?ronde=1&speler='. $row['spelernaam'] .'"><span class="lnk">
'
. $row['spelernaam'] .
'
</span></a></td>
<td><span class="txtpln">
'
. $row['totaal'] .
'
</span></td>
</tr>
</table>';
}
?>
$queryp = "SELECT spelernaam, SUM(totaal) AS totaal FROM rondes GROUP BY spelernaam ORDER BY totaal DESC";
$resultp = mysql_query($queryp);
$nump = mysql_num_rows($resultp);
while ($row = mysql_fetch_array ($resultp)) {
echo '<table width="100%">
<tr>
<td width="50%">
<a href="../spelersinfo/puntenperspeler.php?ronde=1&speler='. $row['spelernaam'] .'"><span class="lnk">
'
. $row['spelernaam'] .
'
</span></a></td>
<td><span class="txtpln">
'
. $row['totaal'] .
'
</span></td>
</tr>
</table>';
}
?>
Maak van je query:
$queryp = "SELECT spelernaam, SUM(totaal) AS totaal FROM rondes GROUP BY spelernaam ORDER BY totaal DESC LIMIT 0,5";
$queryp = "SELECT spelernaam, SUM(totaal) AS totaal FROM rondes GROUP BY spelernaam ORDER BY totaal DESC LIMIT 0,5";