\n"; if (strcmp(strtolower($a) , strtolower ($b)) == 0) return 0; if (strcmp(strtolower($a) , strtolower ($b)) < 0) return -1; return 1; } function mycmp2 ($a, $b) { global $tmvalues; #echo $a,$b,strcmp(strtolower($a) , strtolower ($b)),"
\n"; #print "test:".$tmvalues[$a]; if ($tmvalues[$a] == $tmvalues[$b]) return 0; if ($tmvalues[$a] < $tmvalues[$b]) return 1; return -1; } if(!isset($border) or ($border<0)) $border=0.1; if(!isset($offset1)) { $offset1 = 0; $offset2 = 5; $offset3= 0; $offset4 =30; } if ($offset1 > $offset2) {$offset1=0;}; if ($offset3 > $offset4) {$offset3=0;}; if ($con = mysql_connect("localhost","scholl","tHFA3DGHyyx2zzNK")): $cmd = "select MAX(id) AS id FROM tm_stats"; if ($result = mysql_db_query("scholl_2",$cmd,$con)): ?> \n"; #fetching the row-names (Names of the TMS) $i = 2; while ($i < $cntc) { #echo ""; #sort ($spalten_name); usort ($spalten_name, "mycmp"); $i=0; #reset variables for the tourn/day average $s1=0; $s2=0; $s3=0; $s4=0; #getting the data for the tablerows $cmd = "select * from tm_stats where TO_DAYS(date)=TO_DAYS(NOW())-$offset1"; if ($result = mysql_db_query("scholl_2",$cmd,$con)) { $row1 = mysql_fetch_array($result); } else { print "

Datenbankcommando konnte nicht ausgeführt werden

\n"; } $cmd = "select * from tm_stats where TO_DAYS(date)=TO_DAYS(NOW())-$offset2"; if ($result = mysql_db_query("scholl_2",$cmd,$con)) { $row2 = mysql_fetch_array($result); } else { print "

Datenbankcommando konnte nicht ausgeführt werden

\n"; } $cmd = "select * from tm_stats where TO_DAYS(date)=TO_DAYS(NOW())-$offset3"; if ($result = mysql_db_query("scholl_2",$cmd,$con)) { $row3 = mysql_fetch_array($result); } else { print "

Datenbankcommando konnte nicht ausgeführt werden

\n"; } $cmd = "select * from tm_stats where TO_DAYS(date)=TO_DAYS(NOW())-$offset4"; if ($result = mysql_db_query("scholl_2",$cmd,$con)) { $row4 = mysql_fetch_array($result); } else { print "

Datenbankcommando konnte nicht ausgeführt werden

\n"; } if ($order==2) { #andere Sortierung while($i < $cntc-2) { $t3 = $row3[$spalten_name[$i]]; $t4 = $row4[$spalten_name[$i]]; if (isset($t3) and isset($t4)) { $tmvalues[$spalten_name[$i]] =($t3-$t4); } else { $tmvalues[$spalten_name[$i]] = 0; } $i++; } usort ($spalten_name, "mycmp2"); } $i=0; while($i < $cntc-2) { $t1 = $row1[$spalten_name[$i]]; $t2 = $row2[$spalten_name[$i]]; $t3 = $row3[$spalten_name[$i]]; $t4 = $row4[$spalten_name[$i]]; #calculation for Tourns/Day average if (isset($t3)) { $s3+=$t3; $s4+=$t4; } if (isset($t1)) { $s1+=$t1; $s2+=$t2; } #print out row ! if (isset($t3) and isset($t1)) { echo "\n"; } $i++; } # Printing Last line with tourn/day average echo "\n"; ?>
".mysql_field_name($result, $i)."\n"; $spalten_name[$i-2]=mysql_field_name($result, $i); $i++; } #endwhile; #printing headline of the table echo "
TM $offset4 days ago $offset3 days diff diff/days $offset2 days $offset1 days diff diff/days
".$spalten_name[$i]." "; echo "".$t4."  ".$t3."  ".($t3-$t4); $tmp1=round(($t3-$t4)/($offset4-$offset3)*100)/100; if ($tmp1 < $border) { echo "". $tmp1; } else { echo "". $tmp1; } echo "".$t2."  ".$t1."  ".($t1-$t2); $tmp1=round(($t1-$t2)/($offset2-$offset1)*100)/100; if ($tmp1 < $border) { echo "". $tmp1; } else { echo "". $tmp1; } echo "
Sum ".$s4." ".$s3."".($s3-$s4)." ". round(($s3-$s4)/($offset4-$offset3)*100)/100; echo "".$s2."".$s1." ".($s1-$s2)." ".round(($s1-$s2)/($offset2-$offset1)*100)/100; echo "
Konnte Datenbank nicht öffnen \n"; endif; ?>

Database-Request

Days ago in "; print ""; print ""; print "\n"; ?>
First ColumnSecond ColumnThird ColumnFourth Column

\n"; ?> Order by number of managed tourns

Comments

The sum - row does not reflect tourns, which were run by managers not shown in the list. To include these in average tourns/day look at tms2.php3.