我想得到以下所有值:echo "<td class=\"points\">" . $row2['PIY'] . "/" . $row2['PIK'] . "</td>";
一些如何只返回第一个值。之后我想计算它们的总和。
目前代码只获得第一个。
echo "<table class=\"zebra\">";
$sum1=0;
$sum2=0;
$numbering =1;
$query2 = "SELECT pisteet_1 As PIY, pisteet_2 as PIK, nimi As NIM, opisto As OPI, pisteet.kaupunki_id As KA FROM
pisteet INNER JOIN joukkueet ON joukkueet.id = pisteet.team_id INNER JOIN oppilaitokset ON oppilaitokset.opisto_id = joukkueet.opisto_id GROUP BY nimi, team_id ORDER BY team_id ASC";
foreach ($db->query($query2) as $row2) {
echo "<tr class=\"all " . $row2['KA'] . "\">";
echo "<td>" . $numbering . "</td>";
echo "<td>" . $row2['NIM'] ."<span>" . $row2['OPI'] ."</span></td>";
//--------should get all the points----------
echo "<td class=\"points\">" . $row2['PIY'] . "/" . $row2['PIK'] . "</td>";
$sum1 +=$row2['PIY'];
$sum2 +=$row2['PIK'];
echo '<td class="Sum">'.$sum1.'/'.$sum2."</td>";
//-------------------------------------------
echo "</tr>";
$numbering ++;
}
echo '</table>';