1. 2. 3. osv. i mysql
Jeg har en tabel, hvori der bliver trukket noget ud fra en mysql database, hvordan får jeg gjort sådan at der står 1 2 3 osv nedad for hver række, kode:<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
$con = mysql_connect("localhost","***","***");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("***", $con);
$query = "SELECT player, COUNT(vid) AS count_vid, SUM(population) AS sum_pop FROM x_world GROUP BY player ORDER BY sum_pop DESC";
$result = mysql_query($query) or die(mysql_error());
// Print out result
echo "<table border='1'>
<tr>
<th>Spiller</th>
<th>Byer</th>
<th>Indbyggere</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['player'] . "</td>";
echo "<td>" . $row['count_vid'] . "</td>";
echo "<td>" . $row['sum_pop'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
Output: http://www.traviannews.dk/sta.php
Jeg vil have at står således:
Plads Navn Indbyggere
1. Navn1 782
2. Navn2 640
3. Navn3 639
osv.
