add Statistics

This commit is contained in:
Angelo Cuccato 2010-11-08 23:38:31 +01:00
parent 4cd6081353
commit 0059fd16dd
3 changed files with 76 additions and 42 deletions

View File

@ -1,34 +1,66 @@
<?PHP <?PHP
function funktion_db_list($Table_Name) { function funktion_db_list($Table_Name)
{
global $con; global $con;
$SQL = "SELECT * FROM `".$Table_Name."`"; $SQL = "SELECT * FROM `".$Table_Name."`";
$Erg = mysql_query($SQL, $con); $Erg = mysql_query($SQL, $con);
// anzahl zeilen // anzahl zeilen
$Zeilen = mysql_num_rows($Erg); $Zeilen = mysql_num_rows($Erg);
$Anzahl_Felder = mysql_num_fields($Erg); $Anzahl_Felder = mysql_num_fields($Erg);
echo "<table border=1>"; echo "<table border=1>";
echo "<tr>"; echo "<tr>";
for ($m = 0 ; $m < $Anzahl_Felder ; $m++) { for ($m = 0 ; $m < $Anzahl_Felder ; $m++)
{
echo "<th>". mysql_field_name($Erg, $m). "</th>"; echo "<th>". mysql_field_name($Erg, $m). "</th>";
} }
echo "</tr>"; echo "</tr>";
for ($n = 0 ; $n < $Zeilen ; $n++) { for ($n = 0 ; $n < $Zeilen ; $n++)
{
echo "<tr>"; echo "<tr>";
for ($m = 0 ; $m < $Anzahl_Felder ; $m++) { for ($m = 0 ; $m < $Anzahl_Felder ; $m++)
{
echo "<td>".mysql_result($Erg, $n, $m). "</td>"; echo "<td>".mysql_result($Erg, $n, $m). "</td>";
} }
echo "</tr>"; echo "</tr>";
}
echo "</table>";
} }
echo "</table>"; function funktion_db_element_list_2row( $TopicName, $SQL)
{
global $con;
echo "<table class=\"border\" cellpadding=\"2\" cellspacing=\"1\">\n";
echo "<caption>$TopicName</caption>";
# echo "\t<tr class=\"contenttopic\"> <td><h1>$TopicName</h1></td> </tr>\n";
$Erg = mysql_query($SQL, $con);
echo mysql_error($con);
echo "<tr class=\"contenttopic\">";
for ($m = 0 ; $m < mysql_num_fields($Erg) ; $m++)
{
echo "<th>". mysql_field_name($Erg, $m). "</th>";
}
echo "</tr>";
for ($n = 0 ; $n < mysql_num_rows($Erg) ; $n++)
{
echo "<tr class=\"content\">";
for ($m = 0 ; $m < mysql_num_fields($Erg) ; $m++)
{
echo "<td>".mysql_result($Erg, $n, $m). "</td>";
}
echo "</tr>";
}
echo "</table>\n";
} }
?> ?>

View File

@ -30,33 +30,26 @@ funktion_db_list("FAQ");
echo "Deaktiviert"; echo "Deaktiviert";
*/ */
echo "<br>\n";
funktion_db_element_list_2row( "Tshirt-Size aller engel",
"SELECT `Size`, COUNT(`Size`) FROM `User` GROUP BY `Size`");
echo "<h1>Tshirt-Size aller engel</h1>"; echo "<br>\n";
$SQL="SELECT `Size`, COUNT(`Size`) FROM `User` GROUP BY `Size`"; funktion_db_element_list_2row( "Tshirt ausgegeben",
$Erg = mysql_query($SQL, $con); "SELECT `Size`, COUNT(`Size`) FROM `User` WHERE `Tshirt`='1' GROUP BY `Size`");
echo mysql_error($con);
$rowcount = mysql_num_rows($Erg);
for ($i=0; $i<$rowcount; $i++) echo "<br>\n";
echo mysql_result($Erg, $i, 1). "x '". mysql_result($Erg, $i, 0). "'<br>\n"; funktion_db_element_list_2row( "Tshirt nicht ausgegeben (Gekommen=1)",
"SELECT COUNT(`Size`), `Size` FROM `User` WHERE `Gekommen`='1' and `Tshirt`='0' GROUP BY `Size`");
echo "<h1>Tshirt ausgegeben</h1>"; echo "<br>\n";
$SQL="SELECT `Size`, COUNT(`Size`) FROM `User` WHERE `Tshirt`='1' GROUP BY `Size`"; funktion_db_element_list_2row( "Hometown",
$Erg = mysql_query($SQL, $con); "SELECT COUNT(`Hometown`), `Hometown` FROM `User` GROUP BY `Hometown`");
echo mysql_error($con);
$rowcount = mysql_num_rows($Erg);
for ($i=0; $i<$rowcount; $i++) echo "<br>\n";
echo mysql_result($Erg, $i, 1). "x '". mysql_result($Erg, $i, 0). "'<br>\n"; funktion_db_element_list_2row( "Engeltypen",
"SELECT COUNT(`Art`), `Art` FROM `User` GROUP BY `Art`");
echo "<h1>Tshirt nicht ausgegeben (Gekommen=1)</h1>";
$SQL="SELECT `Size`, COUNT(`Size`) FROM `User` WHERE `Gekommen`='1' and `Tshirt`='0' GROUP BY `Size`";
$Erg = mysql_query($SQL, $con);
echo mysql_error($con);
$rowcount = mysql_num_rows($Erg);
for ($i=0; $i<$rowcount; $i++)
echo mysql_result($Erg, $i, 1). "x '". mysql_result($Erg, $i, 0). "'<br>\n";
include ("../../includes/footer.php"); include ("../../includes/footer.php");
?> ?>

View File

@ -101,6 +101,15 @@ if (!IsSet($_GET["enterUID"]))
"<td>$Gekommen</td><td>$Active</td><td>$Tshirt</td><td></td></tr>\n"; "<td>$Gekommen</td><td>$Active</td><td>$Tshirt</td><td></td></tr>\n";
echo "\t</table>\n"; echo "\t</table>\n";
// Ende Userliste // Ende Userliste
echo "<h1>Statistics</h1>";
funktion_db_element_list_2row( "Hometown",
"SELECT COUNT(`Hometown`), `Hometown` FROM `User` GROUP BY `Hometown`");
echo "<br>\n";
funktion_db_element_list_2row( "Engeltypen",
"SELECT COUNT(`Art`), `Art` FROM `User` GROUP BY `Art`");
} }
else else
{ {