note 90860 deleted from function.mysql-field-name by thiago
| From: | thiago@php.net | Date: | Wed, 13 May 2009 13:05:22 +0000 |
| Subject: | note 90860 deleted from function.mysql-field-name by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154543@lists.php.net to get a copy of this message | ||
Note Submitter: lists headers, data and is sortable
----
<?php
include("dbconnect.php");
$spalte = $_GET["spalte"];
$dir = $_GET["richtung"];
if($dir == "ASC"): $dir = "DESC";
else: $dir = "ASC";
endif;
$query="SELECT * FROM spieler ORDER BY $spalte $dir";
$result=mysql_query($query);
$numfields = mysql_num_fields($result);
echo "<table><tr>";
$counter = 0;
for ($i=0; $i < $numfields; $i++) // Kopf
{
$feld = mysql_field_name($result, $i);
echo "<th><a href=index.php?spalte=". $feld . "&richtung=" . $dir
. ">" . $feld . "</a></th>";
}
echo "</tr>";
while ($row = mysql_fetch_row($result)) // Daten
{
if($counter % 2 == 0): $color = "#FFDDDD";
else: $color = "#DDFFFF";
endif;
echo "<tr bgcolor=". $color . "><td>" .
implode($row,"</td><td>")."</td></tr>";
$counter++;
}
echo "</table>";
?>