954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

calendar problem PHP and MySql

Hi all,

I'm sorry my bad english. If don't understanding something, please ask. I have a problem with my calendar. Can somebody tell me why I can't mark day cell in my calendar. Do I miss something what I can't see or is my code failed? My calendar is full year view calendar and I have start day and end day textboxes, when I click send button days is go to MySql database and should mark day cell to red in calendar in same time. Days gone to MySql fine. I have a form where is datepicker.

Here is the code:

calendar.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);

$act = mysql_query("SELECT * FROM action") or die(mysql_error());

$actlist = array();
while($row = mysql_fetch_array($act)) {
$start = strtotime($row['start1']);
$end = strtotime($row['end1']);
$actlist[] = array($start, $end);

}

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

echo '';
echo '';
echo '';
for ($i=1;$i<=5;$i++)
/*these are weekdays*/
echo 'MaTiKeToPeLaSu';
echo 'MaTi';


echo '';

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 ''.strftime("%B %Y", $aikaleima).'';


//empties
if ($dayofweek == 0) $tyhjia = 6;
//empties
$tyhjia--;
for ($j=-1*$tyhjia; $j<=$amountofdays; $j++) {
//this day
$tamaPV = mktime(0,0,0,$month,1,$year);
if($j == date('j') && $i == 0) {
echo '';

} else {
//act
$tapahtuma = false;
//actlist
foreach ($tapahtumalista as $tl) { //this day //act
if ($tl[0] <= $tamaPV && $tl[1] >= $tamaPV) $tapahtuma = true;
} //act
if ($tapahtuma == true) echo '';
else echo '';
}

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

}
echo '';

}
echo '';


?>

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'])) {
$tunnus = $_POST['tunnus'];
$start1 = $_POST['start1'];
$end1 = $_POST['end1'];

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

$start1 = $yyyy.'-'.$mm.'-'.$dd;
//day
$paiva = explode('.', $end1);
$dd = $paiva[0];
$mm = $paiva[1];
$yyyy = $paiva[2];

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

$insert = "INSERT INTO action VALUES('$tunnus', '$start1', '$end1')";
if (!mysql_query($insert,$conn))
{
die('Error: ' . mysql_error());
}
header("Location: kalenteri2.php");
}
mysql_close($conn);

?>

Please help me, I'm newbie in php. Thanks for advance. :S

make11
Newbie Poster
7 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

Please, help me out of this problem. If something question please ask.

-Make11

make11
Newbie Poster
7 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You