Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot black out previous dates in my calendar - PHP
    primarykey
    data
    text
    <p>I am using a calendar in which i am having trouble making the previous dates unavailable. At the moment my calendar ha links for each date and when you click a date it shows the value on another page. However i need all make all the dates that have already passed unavailable. I know it is something to do with the if statement near the end of the code but i can't figure it out. Here is my code</p> <pre><code>&lt;?php $monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); ?&gt; &lt;?php $cMonth = isset($_REQUEST["month"]) ? $_REQUEST["month"] : date("n"); $cYear = isset($_REQUEST["year"]) ? $_REQUEST["year"] : date("Y"); $prev_year = $cYear; $next_year = $cYear; $prev_month = $cMonth-1; $next_month = $cMonth+1; if ($prev_month == 0 ) { $prev_month = 12; $prev_year = $cYear - 1; } if ($next_month == 13 ) { $next_month = 1; $next_year = $cYear + 1; } ?&gt;&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Hook Up&lt;/title&gt; &lt;/head&gt; &lt;style type="text/css"&gt; table { border: 1px solid black; border-collapse: collapse; } th { border: 1px solid black; padding: 6px; font-weight: bold; background: #ccc; } td { border: 1px solid black; padding: 6px; vertical-align: top; width: 100px; } &lt;/style&gt; &lt;script type="text/javascript"&gt; function eventWindow(url) { event_popupWin = window.open(url, 'event', 'resizable=yes, scrollbars=yes, toolbar=no, width=400, height=400); event_popupWin.opener = self; } &lt;/script&gt; &lt;body&gt; &lt;h1&gt;Select a Night Out&lt;/h1&gt; &lt;table width="200"&gt; &lt;tr align="center"&gt; &lt;td bgcolor="#999999" style="color:#FFFFFF"&gt; &lt;table width="100%" border="0" cellspacing="0" cellpadding="0"&gt; &lt;tr&gt; &lt;td width="50%" align="left"&gt; &lt;a href="&lt;?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&amp;year=" . $prev_year; ?&gt;" style="color:#FFFFFF"&gt;Previous&lt;/a&gt;&lt;/td&gt; &lt;td width="50%" align="right"&gt;&lt;a href="&lt;?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&amp;year=" . $next_year; ?&gt;" style="color:#FFFFFF"&gt;Next&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="center"&gt; &lt;table width="100%" border="0" cellpadding="2" cellspacing="2"&gt; &lt;tr align="center"&gt; &lt;td colspan="7" bgcolor="#999999" style="color:#FFFFFF"&gt;&lt;strong&gt;&lt;?php echo $monthNames[$cMonth-1].' '.$cYear; ?&gt;&lt;/strong&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="center" bgcolor="#999999" style="color:#FFFFFF"&gt;&lt;strong&gt;S&lt;/strong&gt;&lt;/td&gt; &lt;td align="center" bgcolor="#999999" style="color:#FFFFFF"&gt;&lt;strong&gt;M&lt;/strong&gt;&lt;/td&gt; &lt;td align="center" bgcolor="#999999" style="color:#FFFFFF"&gt;&lt;strong&gt;T&lt;/strong&gt;&lt;/td&gt; &lt;td align="center" bgcolor="#999999" style="color:#FFFFFF"&gt;&lt;strong&gt;W&lt;/strong&gt;&lt;/td&gt; &lt;td align="center" bgcolor="#999999" style="color:#FFFFFF"&gt;&lt;strong&gt;T&lt;/strong&gt;&lt;/td&gt; &lt;td align="center" bgcolor="#999999" style="color:#FFFFFF"&gt;&lt;strong&gt;F&lt;/strong&gt;&lt;/td&gt; &lt;td align="center" bgcolor="#999999" style="color:#FFFFFF"&gt;&lt;strong&gt;S&lt;/strong&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php $timestamp = mktime(0,0,0,$cMonth,1,$cYear); $maxday = date("t",$timestamp); $thismonth = getdate ($timestamp); $startday = $thismonth['wday']; $today = date('j'); $currentmonth = date('n'); for ($i=0; $i&lt;($maxday+$startday); $i++) { if(($i % 7) == 0 ){ echo "&lt;tr&gt;"; } if($i &lt; $startday){ echo ("&lt;td class='cell cell_txt'&gt; &lt;/td&gt;"); } else { if (($i - $startday + 1) == $today &amp;&amp; $currentmonth == $cMonth){ echo ("&lt;td class='cell_today cell_txt'&gt;".($i-$startday+ 1)."&lt;/td&gt;"); } else { echo ("&lt;td class='cell cell_txt'&gt;&lt;a href=\"hook.php?day=".($i - $startday + 1)."&amp;amp;month=".$cMonth."&amp;amp;year=".$cYear."\"&gt;".($i - $startday + 1)."&lt;/a&gt;&lt;/td&gt;"); } } if(($i % 7) == 6 ) { echo "&lt;/tr&gt;\n"; } } ?&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>If anyone can help it would be greatly appreciated. Cheers</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload