Jump to content

Having a problem on the event calendar


cruxaders

Recommended Posts

Hi Guys...this is the code of event calendar..

but i got a problem in configuring of the color of the number of days. and the add event button..i want to change it in button but it wont work...

 

Before:

echo "<a href='".$_SERVER['PHP_SELF']."?month=".$month."&day=".$day."&year=".$year."&v=true&f=true'>Add Event</a>";

 

 

after:

echo "<button style='width:65;height:65" onClick="window.location='".$_SERVER['PHP_SELF']."?month=".$month."&day=".$day."&year=".$year."&v=true&f=true''><b>AddEvent</b></button>";

this one wont work.. it says "( ! ) Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\wamp\www\LSGHAA-Website\new.php on line 209

"

can someone help me with this one... tnx

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
mysql_connect("localhost", "root", "") or die (mysql_error());
mysql_select_db("test") or die (mysql_error());

?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Event Calendar</title>

<script>
function goLastMonth(month, year){
if(month == 1) {
--year;
month = 13;
}
--month
var monthstring= ""+month+"";
var monthlength = monthstring.length;
if(monthlength <=1){
monthstring = "0" + monthstring;
}
document.location.href ="<?php $_SERVER['PHP_SELF'];?>?month="+monthstring+"&year="+year;
}
function goNextMonth(month, year){
if(month == 12) {
++year;
month = 0;
}
++month
var monthstring= ""+month+"";
var monthlength = monthstring.length;
if(monthlength <=1){
monthstring = "0" + monthstring;
}
document.location.href ="<?php $_SERVER['PHP_SELF'];?>?month="+monthstring+"&year="+year;
}
</script>
<style type="text/css">
<!--
.a {
   font-family: Georgia, "Times New Roman", Times, serif;
}
.a {
   font-weight: bold;
}
.a {
   font-size: 22px;
}
.a {
   color: #FFF;
}
-->
</style>
<style type="text/css">
<!--
.b {
   font-family: Georgia, "Times New Roman", Times, serif;
}
.b {
   font-weight: bold;
}
.b {
   font-size: 20px;
}
.b {
   color: #0000;
}

.t {
   font-family: Georgia, "Times New Roman", Times, serif;
}
.t {
   font-weight: bold;
}
.t {
   font-size: 22px;
}
.t {
   color: #0000;
}
.today{
background-color: #000000;
}
.event{
background-color: #006600;
}
.normal{
background-color: #000000;
}

-->
</style>
</head>

<body>
<?php
if (isset($_GET['day'])){
$day = $_GET['day'];
} else {
$day = date("j");
}
if(isset($_GET['month'])){
$month = $_GET['month'];
} else {
$month = date("n");
}
if(isset($_GET['year'])){
$year = $_GET['year'];
}else{
$year = date("Y");
}
$currentTimeStamp = strtotime( "$day-$month-$year");
$monthName = date("F", $currentTimeStamp);
$numDays = date("t", $currentTimeStamp);
$counter = 0;
?>
<?php
if(isset($_GET['add'])){
$title =$_POST['txttitle'];
$detail =$_POST['txtdetail'];
$eventdate = $month."/".$day."/".$year;
$sqlinsert = "INSERT into eventcalendar(Title,Detail,eventDate,dateAdded) values ('".$title."','".$detail."','".$eventdate."',now())";
$resultinginsert = mysql_query($sqlinsert);
if($resultinginsert ){
echo "Event was successfully Added...";
}else{
echo "Event Failed to be Added....";
}
}
?>

<table border='0' align="center">
<tr bgcolor="#006600">
<td><input style='width:75px;' type='button' value='<'name='previousbutton' onclick ="goLastMonth(<?php echo $month.",".$year?>)"></td>
<td colspan='5' align = "center" bgcolor="#006600" class="a"><?php echo $monthName.", ".$year; ?></td>
<td><input style='width:75px;' type='button' value='>'name='nextbutton' onclick ="goNextMonth(<?php echo $month.",".$year?>)"></td>
</tr>
<tr>
<td width='75px'class="b" align="center">Sun</td>
<td width='75px'class="b" align="center">Mon</td>
<td width='75px'class="b" align="center">Tue</td>
<td width='75px'class="b" align="center">Wed</td>
<td width='75px'class="b" align="center">Thu</td>
<td width='75px'class="b" align="center">Fri</td>
<td width='75px'class="b" align="center">Sat</td>
</tr>
<?php
echo "<tr bgcolor='#000000'>";
for($i = 1; $i < $numDays+1; $i++, $counter++){
$timeStamp = strtotime("$year-$month-$i");
if($i == 1) {
$firstDay = date("w", $timeStamp);
for($j = 0; $j < $firstDay; $j++, $counter++) {
echo "<td > </td>";
}
}
if($counter % 7 == 0) {
echo"</tr ><tr>";
}
$monthstring = $month;
$monthlength = strlen($monthstring);
$daystring = $i;
$daylength = strlen($daystring);
if($monthlength <= 1){
$monthstring = "0".$monthstring;
}
if($daylength <=1){
$daystring = "0".$daystring;
}
$todaysDate = date("m/d/Y");
$dateToCompare = $monthstring. '/' . $daystring. '/' . $year;
echo "<td align='center'  ";
if ($todaysDate == $dateToCompare){
echo "class ='today'";
} else{
$sqlCount = "select * from eventcalendar where eventDate='".$dateToCompare."'";
$noOfEvent = mysql_num_rows(mysql_query($sqlCount));
if($noOfEvent >= 1){
echo "class='event'";
}
else {
echo "class='normal'";
}
}
echo "><a href='".$_SERVER['PHP_SELF']."?month=".$monthstring."&day=".$daystring."&year=".$year."&v=true'><div>".$i."</div></a></td>";
}
echo "</tr>";
?>
</table>
<?php
if(isset($_GET['v'])) {
echo "<hr>";
echo "<button style="width:65;height:65" onClick="window.location=''.$_SERVER['PHP_SELF']."?month=".$month."&day=".$day."&year=".$year."&v=true&f=true''><b>Home</b></button>";
if(isset($_GET['f'])) {
include("eventform.php");
}
$sqlEvent = "select * FROM eventcalendar where eventDate='".$month."/".$day."/".$year."'";
$resultEvents = mysql_query($sqlEvent);
echo "<hr>";   
while ($events = mysql_fetch_array($resultEvents)){
echo "Title: ".$events['Title']."<br>";
echo "Detail: ".$events['Detail']."<br>";
}
}
?>
</body>
</html>

 

MOD EDIT:

 . . . 

tags added.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.