calendar

Discussion in 'PHP' started by roice, Sep 3, 2012.

  1. #1
    Hello,
    I have table for assignments
    one of the field is "progTargetDate" -> linux time (eg: 1348185600 )
    I also built calender and I want to check if I have any assignment for each day I print

    so - I wrote the query that bring me all the assignment for the current month

    	$query = mysql_query("SELECT ass.id, ass.title, ass.des, ass.progTargetDate 
    							FROM pro_assignments AS ass, pro_progs2assignments AS pr 
    							WHERE 	(ass.progTargetDate >= $ChoosenMonth_start) AND
    									(ass.progTargetDate <= $ChoosenMonth_end) 
    							ORDER BY ass.progTargetDate ASC
    							");
    PHP:
    (I delete part of the SQL query))

    and I have the loop that build the calendar cell
    for ($i = 1 ; $i <= $total_days_in_month ; $i++)
    {
    }
    PHP:
    $i = each day in the month

    I tried to build IF condition without success
    I want to check for each day if it found inside the array (that I got from the first query)

    (this code goes inside the FOR loop:)
    echo "<td>$i"; 
    		while($index = mysql_fetch_array($query)) 
    		{
    				$progTargetDate = $index['progTargetDate'];
    				if ((mktime(0, 0, 0, date($ChoosenMonth)  , $i, date($ChoosenYear)) == $progTargetDate))
    					echo "<p>found</p>";
    				else
    					echo "<p>not</p>";
    
    		}
    									
    echo "</td>";
    PHP:



    What do I do wrong?
     
    roice, Sep 3, 2012 IP