<?
//connect to database
require 'at_dbconnect.php';
//get parameters from URL
$archiveStamp=$_GET['archive_stamp'];
$archiveDate=getdate($archiveStamp);
$stringDate=$archiveDate["year"]."/".$archiveDate["mon"]."/".$archiveDate["mday"];


//set up archive array
$archive=array(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);

      $retrieve= mysql_query(
                     "SELECT fldSymbol0, fldSymbol1, fldSymbol2, fldSymbol3, ".
                     "fldSymbol4, fldSymbol5, fldSymbol6,fldSymbol7, fldSymbol8 ".
                     " FROM tblArchive ".
                     " WHERE fldArchiveDate = '$stringDate' ");

    if (!$retrieve) {
      echo("<P>Error performing query: " .
           mysql_error() . "</P>");
      exit();
    }
    while ( $row = mysql_fetch_array($retrieve) ) {
          $archive[0]=$row["fldSymbol0"];
          $archive[1]=$row["fldSymbol1"];
          $archive[2]=$row["fldSymbol2"];
          $archive[3]=$row["fldSymbol3"];
          $archive[4]=$row["fldSymbol4"];
          $archive[5]=$row["fldSymbol5"];
          $archive[6]=$row["fldSymbol6"];
          $archive[7]=$row["fldSymbol7"];
          $archive[8]=$row["fldSymbol8"];
     }
    //print_r($archive);
   $datestr=$archiveDate['mday']." ".$archiveDate['month'].", ".$archiveDate['year'];

   $strXML  = "";
   $strXML .= "<chart caption='ATMOSPHERE' subcaption='$datestr' xAxisName='Month' yAxisName='Units' showValues='0'    formatNumberScale='0' showBorder='1' baseFont='Trebuchet MS' baseFontSize ='12' baseFontColor ='000000'>";
   $strXML .= "<set label='Sun' value='$archive[0]' color='F5E525'/>";
   $strXML .= "<set label='Cloud & Sun' value='$archive[1]' color='65CBFE' />";
   $strXML .= "<set label='White Cloud' value='$archive[2]'  color='E5D1D1' />";
   $strXML .= "<set label='Black Cloud' value='$archive[3]' color='9B9898' />";
   $strXML .= "<set label='Rain Cloud' value='$archive[4]' color='403E3E'/>";
   $strXML .= "<set label='Lightning' value='$archive[5]' color='FF9933' />";
   $strXML .= "<set label='Fog' value='$archive[6]' color='60865F'/>";
   $strXML .= "<set label='Ice' value='$archive[7]' color='FFFFFF'/>";
   $strXML .= "<set label='Wind' value='$archive[8]' color='856892'/>";
   $strXML .= "</chart>";
   
   echo $strXML;
?>

