"; $html .=" "; if ($_GET['day'] == "") { $day = date("d", time()); } if ($_GET['mon'] == "") { $mon = date("m", time()); } if ($_GET['yr'] == "") { $yr = date("Y", time()); } $strday = mktime(0,0,0,$mon,$day,$yr); $w = date("w", $strday); for ($i=$w; $i>0; $i--) { $pday = $pday + 1; } for ($i=$w; $i<6; $i++) { $nday = $nday + 1; } $pdate = mktime(0,0,0,$mon,$day - $pday,$yr); $ndate = mktime(0,0,0,$mon,$day + $nday,$yr); //$d2 = strtoupper(date("d M Y", $pdate)); //$d3 = strtoupper(date("d M Y", $ndate)); $prev = strtoupper(date("Y-m-d", $pdate)); $next = strtoupper(date("Y-m-d", $ndate)); $start_day = date("d", $pdate); $pweek = mktime(0,0,0,$mon,$day - $pday - 1,$yr); $nweek = mktime(0,0,0,$mon,$day + $nday + 1,$yr); $nextd = date("d", $nweek); $nextm = date("m", $nweek); $nexty = date("Y", $nweek); $prevd = date("d", $pweek); $prevm = date("m", $pweek); $prevy = date("Y", $pweek); $html .= " "; $date2 = ""; if ($_GET['d'] == "y") { $today = date("Y-m-d", time()); $sql = "select * from fpi_event where status='active' and (DATE_FORMAT(date2, '%Y-%m-%d')) ='$today' order by date2"; } else { $sql = "select * from fpi_event where status='active' and (DATE_FORMAT(date2, '%Y-%m-%d')) >='$prev' and (DATE_FORMAT(date2, '%Y-%m-%d')) <='$next' order by date2"; } $result = mysql_query($sql, $conn); while ($myrow = mysql_fetch_object($result)) { $ary = explode(" ",$myrow->date2); $date = explode("-",$ary[0]); $time = explode(":",$ary[1]); $date_text = ""; $bg2 = "#FFFFFF"; if ($ary[0] != $date2) { $t = strtotime($ary[0]); $date_text = date("D", $t)." ".date("M d", $t); $date2 = $ary[0]; $bg2 = "#73A4C5"; } $import = ""; if ($myrow->important == "H") { $bg = "#00B378"; $import = "High"; } else if ($myrow->important == "M") { $bg = "#FEC762"; $import = "Medium"; } else if ($myrow->important == "L") { $bg = "#63B0DE"; $import = "Low"; } $fore = ""; if ($myrow->forecast) { $fore = $myrow->forecast."%"; } $previous = ""; if ($myrow->previous2) { $previous = $myrow->previous2."%"; } $photo = ""; $sql = "select * from fpi_country where status='active' and id='$myrow->cty_id'"; $result2 = mysql_query($sql, $conn); if ($myrow2 = mysql_fetch_object($result2)) { $photo = $myrow2->name_chi; //if ($myrow->photo != "") { //$photo = ""; //} } $html .= " "; $i ++; } $html .= "
 Date Time Currency Event Importance Forecast Previous Note
 ".$date_text."  ".$time[0].":".$time[1]."  ".$photo."  ".$myrow->name_chi."  ".$import."  ".$fore."  ".$previous."  ".LF2BR($myrow->note_chi)."
"; $file_ending = "xls"; header("Content-type: application/vnd.ms-excel; charset=utf-8"); if ($act == "html") { $file_ending = "html"; header("Content-type: text/html; charset=utf-8"); } header("Content-Disposition: attachment; filename=$now_date.$file_ending"); header("Pragma: no-cache"); header("Expires: 0"); print "$header\n$html"; ?>