Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>if you add following line </p> <pre><code>$cDay = isset($_REQUEST["day"]) ? $_REQUEST["day"] : date("d"); </code></pre> <p>below this line</p> <pre><code>$cYear = isset($_REQUEST["year"]) ? $_REQUEST["year"] : date("Y"); </code></pre> <p>and change this line</p> <pre><code>if (($i - $startday + 1) == $today &amp;&amp; $currentmonth == $cMonth){ </code></pre> <p>to:</p> <pre><code>if ((($i - $startday + 1) == $today &amp;&amp; $currentmonth == $cMonth) OR ( (($i - $startday + 1) == $cDay) &amp;&amp; ($currentmonth == $cMonth)) ){ </code></pre> <p>That will black out the date that is passed in.</p> <p>If you want to pass in multiple dates, i.e. pick one date 2013-01-18, the page reloads and blanks out the 18th then want to pick a second date e.g. 2013-01-22 and have the page reload and blank out both the 18th and the 22nd then you will need to change the inputs to arrays and add the previous selected dates into hidden fields to be resubmitted.</p> <p>If you just want to black out one date then the code changes will work.</p> <p>Hope this helps.</p> <p><strong>Update to black out all previous date to the selected:</strong></p> <pre><code>&lt;?php $monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); ?&gt; &lt;?php $sMonth = isset($_REQUEST["smonth"]) ? $_REQUEST["smonth"] : date("n"); $sYear = isset($_REQUEST["syear"]) ? $_REQUEST["syear"] : date("Y"); $cMonth = isset($_REQUEST["month"]) ? $_REQUEST["month"] : ''; $cYear = isset($_REQUEST["year"]) ? $_REQUEST["year"] : ''; $cDay = isset($_REQUEST["day"]) ? $_REQUEST["day"] : ''; //echo __line__." Dates in ".$cDay." ".$cMonth.", ".$cYear."&lt;br&gt;"; $prev_year = $sYear; $next_year = $sYear; $prev_month = $sMonth - 1; $next_month = $sMonth + 1; if ($prev_month == 0) { $prev_month = 12; $prev_year = $sYear - 1; } if ($next_month == 13) { $next_month = 1; $next_year = $sYear + 1; } $nextPrevString = "&amp;amp;month=$cMonth&amp;amp;year=$cYear&amp;amp;day=$cDay"; $selectString = "&amp;amp;smonth=$sMonth&amp;amp;syear=$sYear"; ?&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"] . "?smonth=" . $prev_month . "&amp;syear=" . $prev_year . $nextPrevString; ?&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"] . "?smonth=" . $next_month . "&amp;syear=" . $next_year . $nextPrevString; ?&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[$sMonth - 1] . ' ' . $sYear; ?&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, $sMonth, 1, $sYear); if ($cDay != '') { $selectedDate = mktime(0, 0, 0, $cMonth, $cDay, $cYear); } else { $selectedDate = 0; } $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 { $testDate = mktime(0, 0, 0, $sMonth, $i - $startday + 1, $sYear); if ($testDate &lt; $selectedDate) { 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=\"" . $_SERVER['PHP_SELF'] . "?day=" . ($i - $startday + 1) . "&amp;amp;month=" . $sMonth . "&amp;amp;year=" . $sYear . $selectString . "\"&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>
 

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