Hi All,
I put my code here again in english, it may so easier to understand what I mean. I also put adress where you can go and see my problem what I ask before. Code:
kalenteri6.php
<?php
setlocale(LC_TIME, "fin");
$dbuser="root";
$dbpass="";
$host="localhost";
$conn=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("Query did not succeed:". 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="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>';
for ($i=0; $i<12; $i++) {
$timestamp = mktime(0,0,0,$month+$i,$j,$year);
$dayofweek = date('w', $timestamp);
$amountofdays = date('t', $timestamp);
$empties = $dayofweek-1;
echo '<td style=\"width: 20px; text-align: center;\">'.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 ($action == $start){
echo '<img style="width: 5px; height: 5px;" alt="start" src="start.gif"'.$row['start1'].' />';
} else { ($action == $end);
echo '<img style="width: 5px; height: 5px;" alt="end" src="end.gif"'.$row['end1'].' />';
}
}
if ($j>0 && ($i>0 || $j>=date('j'))) echo $j;
else echo ' ';
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
mysql_close($conn);
?>
insert.php
<?php
$dbuser="root";
$dbpass="";
$host="localhost";
$conn=mysql_connect($host, $dbuser, $dbpass) or die(mysql_error());
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("lincal", $conn);
if (isset($POST['submit'])) {
$id = $POST["id"];
$start1 = $POST["start1"];
$end1 = $POST["end1"];
$day = explode('.', $start1);
$dd = $day[0];
$mm = $day[1];
$yyyy = $day[2];
$start1 = $yyyy.'-'.$mm.'-'.$dd;
$day = explode('.', $end1);
$dd = $day[0];
$mm = $day[1];
$yyyy = $day[2];
$end1 = $yyyy.'-'.$mm.'-'.$dd;
$insert = "INSERT INTO actions (id, start1, end1) VALUES ('$id', '$start1', '$end1')";
if (!mysql_query($insert,$conn))
{
die('Error: ' . mysql_error());
}
header("Location: kalenteri6.php");
}
mysql_close($conn);
?>
In here you see the calendar: http://www.laaksontt.net/kalenteri6.php
Is there someone who can help with my calendar, please? I need help very badly 🙁
-Marko