<?php ob_start();

 session_start();

include($_SERVER['DOCUMENT_ROOT'].'/includes/connection.php');

//mysql_query("delete from moon_calendar");

?> 

<?php

$year=$_REQUEST['year'];

$month=$_REQUEST['month'];

$monthname=strtoupper(date("F",strtotime($year."-".$month."-01")));

  echo '<p style="text-align:center; font-size:x-large; color:#ebb85d;"><b>MOON CALENDAR - '.$monthname.'&nbsp;'.$year.'</b></p><div class="rTable2">';

	/* table headings */

	$headings = array('SUN','MON','TUE','WED','THU','FRI','SAT');

	echo '<div class="rTableRow2" style="text-align:center; background: linear-gradient(to bottom, #613600, #b47100);"><div class="rTableCell2" style="text-align:center; color:#000000;"><strong>'.implode('</strong></div><div class="rTableCell2" style="text-align:center; color:#000000;"><strong>',$headings).'</strong></div></div>';

    $running_day = date('w',mktime(0,0,0,$month,1,$year));

	$days_in_month = date('t',mktime(0,0,0,$month,1,$year));

	$days_in_this_week = 1;

	$day_counter = 0;

	$dates_array = array();

	/* row for week one */

	echo '<div class="rTableRow2"> ';    

 	/* print "blank" days until the first of the current week */

	for($x = 0; $x < $running_day; $x++):

		echo '<div class="rTableCell2" style="text-align:center; vertical-align:top; background-color:#84500d;">&nbsp;</div>';

		$days_in_this_week++;

	endfor;

		for($list_day = 1; $list_day <= $days_in_month; $list_day++):

	 $cal_date=$month."/".$list_day."/".$year;

	  $date=date('Y-m-d',strtotime($cal_date));

	  $catquery=mysql_query("select * from moon_calendar where moondate like '%".$date."%'   order by moondate asc");

  $linktxt="";

 	while($noticia = mysql_fetch_array($catquery))

 	{ 

$newmoon="";

$firstquarter="";

$fullmoon="";

$lastquarter="";

$solar="";

$lunar="";

$vocstart="";

$vocend="";

$aries="";

$taurus="";

$gemini="";

$cancer="";

$leo="";

$virgo="";

$libra="";

$scorpio="";

$sagittarius="";

$capricorn="";

$aquarius="";

$pisces="";

 if ($noticia['newmoon']==true)

{

 $newmoon = "<img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/newmoon.png' title='New Moon' alt='New Moon' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['newtime']."<br><br>";

  }

 if ($noticia['firstquarter']==true)

{

 $firstquarter =" <img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/first.png' title='First Quarter' alt='First Quarter' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['firsttime']."<br><br>";

  }

  if ($noticia['fullmoon']==true)

{

 $fullmoon =" <img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/fullmoon.png' title='Full Moon' alt='Full Moon' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['fulltime']."<br><br>";

  }

 if ($noticia['lastquarter']==true)

{

 $lastquarter =" <img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/last.png' title='Last Quarter' alt='Last Quarter' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['lasttime']."<br><br>";

  }

 if ($noticia['solar']==true)

{

 $solar =" <img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/solar.png'  alt='Solar Eclipse' title='Solar Eclipse' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['solartime']."<br><br>";

  }

 if ($noticia['lunar']==true)

{

 $lunar =" <img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/lunar.png'  alt='Lunar Eclipse' title='Lunar Eclipse' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['lunattime']."<br><br>";

  }

 if ($noticia['vocstart']==true)

{

 $vocstart =" <img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/voidstart.png'  alt='Void of Course Start' title='Void of Course Start' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['vocsttime']."<br><br>";

  }

if ($noticia['vocend']==true)

{

 $vocend = "<img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/voidend.png'  alt='Void of Course End' title='Void of Course End' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['vocedtime']."<br><br>";

  }

if ($noticia['aries']==true)

{

 $aries = "<img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/ari.png' alt='Aries' title='Aries' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['ariestime']."<br><br>";

  }

if ($noticia['taurus']==true)

{

$taurus = "<img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/tau.png' title='Taurus' alt='Taurus' width='20' height='20' style='vertical-align:middle;'>&nbsp;".$noticia['taurustime']."<br><br>";

  }

if ($noticia['gemini']==true)

{

 $gemini = "<img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/gem.png' title='Gemini' alt='Gemini' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['geminitime']."<br><br>";

 }

if ($noticia['cancer']==true)

{

 $cancer  ="<img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/can.png' title='Cancer' alt='Cancer' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['cancertime']."<br><br>";

 }

if ($noticia['leo']==true)

{

 $leo = "<img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/leo.png' title='Leo' alt='Leo' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['leotime']."<br><br>";

 }

 if ($noticia['virgo']==true)

{

 $virgo= "<img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/vir.png' title='Virgo' alt='Virgo' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['virgotime']."<br><br>";
 
 }

if ($noticia['libra']==true)

{

 $libra = "<img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/lib.png' title='Libra' alt='Libra' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['libratime']."<br><br>";

 }

 if ($noticia['scorpio']==true)

{

 $scorpio= "<img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/sco.png' title='Scorpio' alt='Scorpio' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['scorpiotime']."<br><br>";

 }

if ($noticia['sagittarius']==true)

{

$sagittarius= "<img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/sag.png' title='sagittarius' alt='sagittarius' width='20' height='20' style='vertical-align:middle;'>&nbsp;".$noticia['sagittariustime']."<br><br>";

 }

if ($noticia['capricorn']==true)

{

$capricorn=  "<img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/cap.png' title='Capricorn' alt='Capricorn' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['capricorntime']."<br><br>";

 }

if ($noticia['aquarius']==true)

{

$aquarius = "<img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/aqu.png' title='aquarius' alt='aquarius' width='20' height='20'>&nbsp;".$noticia['aquariustime']."<br><br>";  

 }

if ($noticia['pisces']==true)

{

  $pisces = "<img src='https://www.findyourfate.com/astrology/year2017/moon-calendar/images/pis.png' title='Pisces' alt='Pisces' width='20' height='20'  style='vertical-align:middle;'>&nbsp;".$noticia['piscestime']."<br><br>";

 }

 $linktxt=$noticia['moondate'];
 
 $linktxt=$newmoon.$fullmoon.$firstquarter.$lastquarter.$solar.$lunar.$vocstart.$vocend;

 $linktxt.=$aries.$taurus.$gemini.$cancer.$leo.$virgo.$libra.$scorpio.$sagittarius.$capricorn.$aquarius.$pisces;

 }
		echo '<div class="rTableCell2" style="text-align:center; vertical-align:top; background-color:#84500d;">';

			/* add in the day number */

			echo $list_day."<div><br>".$linktxt."</div>";

			/** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !!  IF MATCHES FOUND, PRINT THEM !! **/

			 echo str_repeat('<p> </p>',1);

		echo '</div>';

		if($running_day == 6):

			echo '</div>';

			if(($day_counter+1) != $days_in_month):

				echo '<div class="rTableRow2">';

			endif;

			$running_day = -1;

			$days_in_this_week = 0;

		endif;

		$days_in_this_week++; $running_day++; $day_counter++;

	endfor;

	/* finish the rest of the days in the week */

	if($days_in_this_week < 8):

		for($x = 1; $x <= (8 - $days_in_this_week); $x++):

			echo '<div class="rTableCell2" style="text-align:center; vertical-align:top; background-color:#84500d;"> </div>';

		endfor;

	endif;

	/* final row */

	echo '</div>';

 echo '</div><br>';

	/* all done, return result */

	//echo  $calendar;

mysql_close($link);

?>		 