Reputation: 73
I have a stats table now.
But what i want is this:
1.|Team
2.|Team
3.|Team
I dont have de numbers before the teams. My table is ordered by "Punten" so it can't be added with a team. it needs to be static befor the td
This is my code:
<?php
$table = "e2teams";
$sql = "SELECT ID, Team, Punten, Gespeeld, Gewonnen, Verloren, Gelijk, DPV, DPT, DPV-DPT AS Verschil FROM e2teams ORDER BY Punten DESC, Verschil DESC, DPV DESC";
$result = mysql_query($sql, $dbhandle);
echo "<table class='opmaaktable'><tr><td class='styled-td'>Team</td><td class='styled-td2'>G</td><td class='styled-td2'>W</td><td class='styled-td2'>GL</td><td class='styled-td2'>V</td><td class='styled-td2'>P</td><td class='styled-td2'>DPV</td><td class='styled-td2'>DPT</td><td class='styled-td2'>Vers.</td></tr></table>";
if(mysql_num_rows($result) > 0){
$team = array();
while($row = mysql_fetch_array($result)) {
echo "<table><tr><td class='styled-td'>";
echo $row['Team']. '</td><td class="styled-td2">';
echo $row['Gespeeld']. '</td><td class="styled-td2">';
echo $row['Gewonnen']. '</td><td class="styled-td2">';
echo $row['Gelijk']. '</td><td class="styled-td2">';
echo $row['Verloren']. '</td><td class="styled-td2">';
echo $row['Punten']. '</td><td class="styled-td2">';
echo $row['DPV']. '</td><td class="styled-td2">';
echo $row['DPT']. '</td><td class="styled-td2">';
echo $row['Verschil']. '</td><td class="styled-td2">';
echo "</td></tr></table>";
$team = $row['Team'];
}
}
?>
And this is how it looks like:
Hope you can help!
Upvotes: 0
Views: 80
Reputation: 57326
I'm not sure if I'm missing something - but why not just declare a counter and increment it in the loop?
$ctr = 1;
while($row = mysql_fetch_array($result)) {
echo "<table><tr><td class='styled-td'>";
echo "$ctr." . $row['Team']. '</td><td class="styled-td2">';
...
$ctr++;
}
Upvotes: 3