$server="localhost"; $user="CAS"; $pw="lotuselanK1!"; $cn = mysql_connect ($server,$user,$pw) or die('bollocks'); mysql_select_db("csdb"); echo "\n"; echo "
\n"; echo "\n"; $sqlq = "select count(usr_id) from usrs"; $rs = mysql_query($sqlq); $k = mysql_fetch_row($rs); echo "Number Of Users : ".$k[0]."\n"; echo "\n"; $sqlq = "select count(tmp_id) from temps"; $rs = mysql_query($sqlq); $k = mysql_fetch_row($rs); echo "Number Of Temperature Entries : ".$k[0]."\n"; echo "\n"; for ($i=1;$i<=12;$i++) { $numdays = 31; for ($j=1;$j<=$numdays;$j++) { $days[$i][$j] = ' '; } } $sqlq = "select count(tmp_id), tmp_month, tmp_day from temps group by tmp_month, tmp_day order by tmp_month, tmp_day"; $rs = mysql_query($sqlq); $NumRows = mysql_num_rows($rs); echo "Number Of Days with an entry : ".$NumRows."\n"; echo "\n"; echo "Number Of Days without an entry: ".(365 - $NumRows)."\n"; echo "\n"; $sqlq = "select * from temps order by tmp_year desc, tmp_month desc, tmp_day desc"; $rs = mysql_query($sqlq); $k = mysql_fetch_row($rs); echo "Most recent entry : ".$k[5]."C on ".$k[4]."/".$k[3]."/".$k[2]."\n"; echo "\n"; echo "\n"; $sqlq = "select count(tmp_id), tmp_month, tmp_day from temps group by tmp_month, tmp_day order by tmp_month, tmp_day"; $rs = mysql_query($sqlq); $NumRows = mysql_num_rows($rs); for ($i=1;$i<=$NumRows;$i++) { $k = mysql_fetch_row($rs); $days[$k[1]][$k[2]] = $k[0]; } $days[2][30] = ' '; $days[2][31] = ' '; $days[4][31] = ' '; $days[6][31] = ' '; $days[9][31] = ' '; $days[11][31] = ' '; echo "Entries by day (X > 10)\n"; echo "-----------------------\n"; echo "\n"; echo " Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec\n"; echo " +----------------------------------------------------------\n"; for ($i=1;$i<=31;$i++) { if ($i < 10) { echo " "; } echo $i."|"; for ($j=1;$j<=12;$j++) { if ($days[$j][$i] > 10) { echo " X "; } else { echo " ".$days[$j][$i]." "; } } echo "\n"; } echo " +----------------------------------------------------------\n"; echo "T |Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec\n"; echo "o +----------------------------------------------------------\n"; echo "t |"; for ($i=1;$i<=12;$i++) { $numdays = 0; for ($j=1;$j<=31;$j++) { $numdays = $numdays + $days[$i][$j]; } echo $numdays; if ($numdays < 10) { echo " "; } elseif ($numdays < 100) { echo " "; } else { echo " "; } } echo "\n"; echo "\n"; echo "\n"; ?>