Hi all,

I'm sorry my bad english. I have a problem with my calendar. How I can mark in a date cell half day booked? Which is better image from mysql or do in php code. Have anybody there any example or could you show me how to do? I can get full day mark in my calendar, that is all right, but how I can get half day booked? Now I get full day booked, why my code mark red also empty cells? Here is the code there is not all:

calendar.php

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

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

$yhteys=mysql_connect($host, $dbuser, $dbpass) or die(mysql_error());
if (!$yhteys)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("lincal", $yhteys);
//$action
$tapahtumat = mysql_query("SELECT * FROM tapahtuma" , $yhteys) or die("Kysely ei onnistunut:". mysql_error());
// loop every happens throught and save into array
//happenslist
$tapahtumalista = array();
while ($row = mysql_fetch_array($tapahtumat)) {
    $alku = strtotime($row['alko1']);
    $loppu = strtotime($row['loppu1']);
    $tapahtumalista[] = array($alku, $loppu);

}

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

echo '<table width="90%" border="0px #009 solid; cellspacing="10" cellpadding="0" style="text-align: center">';
echo "<tr>";
echo "<th></th>";
for ($i=1;$i<=5;$i++)
          /*these are weekdays*/
   echo '<th style="width: 25px;">Ma</th><th style="width: 25px;">Ti</th><th>Ke</th><th style="width: 25px;">To</th><th>Pe</th><th>La</th><th style="width: 30px;">Su</th>';
echo '<th>Ma</th><th>Ti</th>';
//echo "</tr>";
echo '<tr>';

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

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


    //$empties
    $tyhjia = $dayofweek-1;


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


                          //$empties
    if ($dayofweek == 0) $tyhjia = 6;
    $tyhjia--;
    for ($j=-1*$tyhjia; $j<=$amountofdays; $j++) {
    //this day
    $tamaPV = mktime(0,0,0,$kk+$i,$j,$vuosi);

        if($j == date('j') && $i == 0) {
          echo '<td bgcolor= "yellow" span style="color: red;">';

        } else {
          $tapahtumat = false;
                      //list
          foreach ($tapahtumalista as $tl) {
              if ($tl[0] <= $tamaPV && $tl[1] >= $tamaPV) $tapahtumat = true;
             }
          if($tapahtumat == 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($yhteys);
?> 

insert.php

<?php
$dbuser="root";
$dbpass="";
$host="localhost";

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

if (isset($_POST['submit'])) {
$tunnus = $_POST["tunnus"];
$alko1 = $_POST["alko1"];
$loppu1 = $_POST["loppu1"];


$paiva = explode('.', $alko1);
$dd = $paiva[0];
$mm = $paiva[1];
$yyyy = $paiva[2];

$alko1 = $yyyy.'-'.$mm.'-'.$dd;

$paiva = explode('.', $loppu1);
$dd = $paiva[0];
$mm = $paiva[1];
$yyyy = $paiva[2];

$loppu1 = $yyyy.'-'.$mm.'-'.$dd;

$insert = "INSERT INTO tapahtuma (tunnus, alko1, loppu1) VALUES ('$tunnus', '$alko1', '$loppu1')";
if (!mysql_query($insert,$yhteys))
  {
  die('Error: ' . mysql_error());
  }

}
mysql_close($yhteys);

?> 

Thank's for advance. Help me, please!!! :)

Hi,

Is this real, nobody can help me???? Where is all php guru's? Please help me!!!! :)

-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.