By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,538 Members | 875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,538 IT Pros & Developers. It's quick & easy.

php calendar to generate checkboxes next to each date

P: n/a
does anyone know of a script that would produce a calendar starting
from todays date with checkboxes next to every day of the month so that
the user is able to check it in case of an event for that day...
without specifying what the event is... just a simple checkbox..

Apr 19 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
NC
Kentor wrote:

does anyone know of a script that would produce a calendar starting
from todays date with checkboxes next to every day of the month so that
the user is able to check it in case of an event for that day...
without specifying what the event is... just a simple checkbox..


Something like this should do the trick:

$timestamp = time();
$month = date('m', $timestamp);
while ($month == date('m', $timestamp)) {
$dateMDY = date('F j, Y', $timestamp);
$dateYMD = date('Y-m-d', $timestamp);
echo "<input type='checkbox' name='dates[]' ",
"value='$dateYMD'>$dateMDY<br>\r\n";
$timestamp = $timestamp + 24*60*60;
}

This will give you a checkbox for every day from today until the end of
the current month... The list (or, rather, array) of checked dates
will be available to the receiving script as $_POST['dates'] or
$_GET['dates'], depending on what method the form uses.

Cheers,
NC

Apr 19 '06 #2

P: n/a
On 18 Apr 2006 17:18:33 -0700, "Kentor" <ke****@gmail.com> wrote:
does anyone know of a script that would produce a calendar starting
from todays date with checkboxes next to every day of the month so that
the user is able to check it in case of an event for that day...
without specifying what the event is... just a simple checkbox..


Modify something like this:
<http://www.micronetwork.de/activecalendar/>

--
Locate your Mobile phone: <http://www.bizorg.co.uk/news.html>
Great gifts: <http://www.ThisBritain.com/ASOS_popup.html>
Apr 19 '06 #3

P: n/a
perfect this little php script would do :) and i suppose
http://www.micronetwork.de/activecalendar/ would also work.. i just
need to play with it a bit.
NC: how would i display this for 12 months ahead, starting from the
current date? and have it all sorted by months only showing the date
number and the month as a header for each month, and then a big year
header for the 2 years that would appear?

Apr 19 '06 #4

P: n/a
and also how would go about storing the checked boxes in the database
for faster usage and retrieving those dates that have been checked so i
could display a calendar with different colors for checked/non checked
dates? :)

Apr 19 '06 #5

P: n/a
NC
Kentor wrote:

NC: how would i display this for 12 months ahead, starting from the
current date? and have it all sorted by months only showing the date
number and the month as a header for each month, and then a big
year header for the 2 years that would appear?


$timestamp = time();
$cutoff = strtotime(date('Y-m-d 23:59:59', $timestamp) . ' + 1 year');
// you could use $cutoff = $timestamp + 365*24*60*60,
// but it ignores leap year...
$year = date('Y', $timestamp);
$month = date('m', $timestamp);
$month_text = date('F', $timestamp);
echo "<h1>$year</h1>\r\n";
echo "<h2>$month_text</h2>\r\n<p>";
while ($timestamp <= $cutoff) {
if ($year <> date('Y', $timestamp)) {
$year = date('Y', $timestamp);
echo "<h1>$year</h1>\r\n";
}
if ($month <> date('m', $timestamp)) {
$month = date('m', $timestamp);
$month_text = date('F', $timestamp);
echo "<h2>$month_text</h2><p>\r\n";
}
$day = date('j', $timestamp);
$dateYMD = date('Y-m-d', $timestamp);
echo "<input type='checkbox' name='dates[]' ",
"value='$dateYMD'>$day \r\n";
$timestamp = $timestamp + 24*60*60;
}

Cheers,
NC

Apr 19 '06 #6

P: n/a
awsome, i just need to make this look nice now :)

Apr 19 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.