Hi All,

Sorry my bad english. I have a problem with my calendar. How I can mark table cells with image and with checkbox? I have a linear year calendar what show booked -> red and free -> green. Now I want when booking calendar and booking first day of cell is am afternoon and last day is pm evening, what I have to do?
When checkbox1 is true then
checkbox1 -> am status green-red.gif

When checkbox2 is true
checkbox2 -> pm status red-green.gif

Where I put checkbox code? I assume that in mysql I have to create status field?

Here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//FI" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fi" lang="fi">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />

<title>Linear Calendar</title>

<link rel="stylesheet" href="calendar.css" />
<script language="JavaScript" src="calendar_eu.js"></script>
<style type="text/css">

.start{ background-image: url(alku1.gif);
       background-repeat: no-repeat;
  background-position: top left}
.end{ background-image: url(loppu1.gif);
        background-repeat: no-repeat;
  background-position: top left
}

</style>

</head>

<body>

<?php
setlocale(LC_TIME, "fin");

$dbuser="root";
$dbpass="";
$host="localhost";

$yhteys=mysql_connect($host, $dbuser, $dbpass) or die(mysql_error());
if (!$conn)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("lincal", $conn);

$today = date('Y-n-j');

$action = mysql_query("SELECT * FROM actions WHERE start1 >= '$today'", $conn) or die("Kysely ei onnistunut:". mysql_error());

$actionlist = array();
while ($row = mysql_fetch_array($action)) {

    $start = strtotime($row['start1']);
    $end = strtotime($row['end1']);
    $actionlist[] = array($start, $end);

}

$month = date('n');
$year = date('Y');
$day = date('j');

echo '<table width="100%" border="2px #009 solid; cellspacing="10" cellpadding="0" style="text-align: center">';
echo "<tr>";
echo "<th>month</th>";
for ($i=1;$i<=5;$i++)

//these are weekdays, mo,tu,we,th,fr,sa,su..          
echo '<th style="width: 25px;">Ma</th><th style="width: 25px;">Ti</th><th style="width: 25px;">Ke</th><th style="width: 25px;">To</th><th style="width: 25px;">Pe</th><th style="width: 25px;" bgcolor= "#ECECFF">La</th><th style="width: 25px;" bgcolor= "#E2E2EB">Su</th>';
echo '<th style="width: 25px;">Ma</th><th style="width: 25px;">Ti</th>';

echo '<tr>';

for ($i=0; $i<12; $i++) {

    $timestamp = mktime(0,0,0,$month+$i,1,$year);
    $dayofweek = date('w', $timestamp);
    $amountofdays = date('t', $timestamp);    

    $empties = $dayofweek-1;    

    echo '<td style=\"width: 20px; text-align: center;\" bgcolor="#FEFEFE">'.strftime("%B %Y", $timestamp).'</td>';

    if ($dayofweek == 0) $empties = 6;

    $empties--;    

    for ($j=-1*$empties; $j<=$amountofdays; $j++) {

    $thisDay = mktime(0,0,0,$month+$i,$j,$year);    

        if ($j == date('j') && $i == 0) {
          echo '<td bgcolor= "yellow" span style="color: red;" />';          
        } else {
          $action = false;
          foreach ($actionlist as $tl) {
              if ($tl[0] <= $thisDay && $tl[1] >= $thisDay) $action = true; 
             }

             if ($action == true){
                echo '<td bgcolor="red" />';             
             else echo '<td bgcolor="#91CD92" />';          


        }        

        if ($j>0 && ($i>0 || $j>=date('j'))) echo $j;
        else echo '&nbsp;';
         echo '</td>';

    }
        echo '</tr>';

}
echo '</table>';

mysql_close($conn);
?>

<form name="lomake" action="insert.php" method="post" />
<input name="tunnus" value="" size="" type="hidden" />
<center><p>
Alkaa pvm <input name="alko1" size="12" id="alko1" type="text" />
        <script language="JavaScript">
var o_cal = new tcal ({
// lomakkeen nimi
'formname': 'lomake',
// kentän nimi
'controlname': 'alko1'
});

o_cal.a_tpl.yearscroll = false;
o_cal.a_tpl.weekstart = 1; 
        </script>
<span style="padding-left: 19px;">Päättyy pvm <input name="loppu1" size="12" id="loppu1" type="text" />
        <script language="JavaScript">

var A_CALTPL = {
'months' : ['Tammi', 'Helmi', 'Maalis', 'Huhti', 'Touko', 'Kesä', 'Heinä', 'Elo', 'Syys', 'Loka', 'Marras', 'Joulu'],
'weekdays' : ['su', 'ma', 'ti', 'ke', 'to', 'pe', 'la'],
'yearscroll': true,
'weekstart': 1,
'centyear' : 70,
'imgpath' : ''
}
new tcal ({

'controlname': 'loppu1'
}, A_CALTPL);

</script>

   &nbsp;&nbsp;<input style="width: 40;" type="submit" name="submit" value="Lähetä" />
</form>
</body>
</html>

Help me, please. Thanks for help in advance.

Hi All,

More details in this post. This post consider that if want to booking afternoon and in the calendar comes half day image on the table cell I mean it mark table cell in half day image? And with checkbox. First come day-month-year field and then you can choose half day with checkbox and when you put it in database you have first booked day half day image in the calendar. Does some one have any ideas in that kind of design? What I have to do in theory?

-Make

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.