Hi,

I am trying to modify these codes to where I can use my PHP /MySql Database.

I have an event section in the database that list the month year and day of the event as well as the title of event and description.

As of now I have all the event being show on the events page, but my client would like it where the calendar lets the users click on it to see all the events on that day.

I would also I like it if I could let the day of the event changes background color and text (according if there is something in the database with that particular date)

Can someone please help me? Thank you in advance ^_^

Codes are here:

$x=$_GET[x];
if($x=="") $x = date("n");

$date = strtotime("2006/$x/1");
$day = date("D",$date);
$m = date("F",$date);
$totaldays = date("t",$date); //get the total day of specified date

echo "<table border = '1' cellspacing = '0' bordercolor='blue' cellpadding ='2'><tr>
<td colspan='7'>$m</td></tr>
<tr>
<td><font size = '1' face = 'tahoma'>Sun</font></td>
<td><font size = '1' face = 'tahoma'>Mon</font></td>
<td><font size = '1' face = 'tahoma'>Tue</font></td>
<td><font size = '1' face = 'tahoma'>Wed</font></td>
<td><font size = '1' face = 'tahoma'>Thu</font></td>
<td><font size = '1' face = 'tahoma'>Fri</font></td>
<td><font size = '1' face = 'tahoma'>Sat</font></td>
</tr>
";

if($day=="Sun") $st=1;
if($day=="Mon") $st=2;
if($day=="Tue") $st=3;
if($day=="Wed") $st=4;
if($day=="Thu") $st=5;
if($day=="Fri") $st=6;
if($day=="Sat") $st=7;

if ($st >= 6 && $totaldays == 31) {
$tl=42;
}elseif($st == 7 && $totaldays == 30){
$tl = 42;
}else{
$tl = 35;
}

$ctr = 1;
$d=1;

for($i=1;$i<=$tl;$i++){

if($ctr==1) echo "<tr>";

if($i >= $st && $d <= $totaldays){
echo "<td align='center'><font size = '2' face = 'tahoma'>$d</font></td>";
$d++;
}
else{
echo "<td>&nbsp</td>";
}

$ctr++;

if($ctr > 7) {
$ctr=1;
echo "</tr>";
}

}

$prev=$x - 1;
$next = $x + 1;
if($prev==0) $prev=1;
if($next==13) $next = 12;
echo "</table><b><a href = 'calendar.php?x=$prev'>Previous</a>                  <a href = 'calendar.php?x=$next'>Next</a></b>";
Member Avatar for diafol

How are you event dates stored? timestamps?

They are stored with a date function as well as individually such as table named month, day, and year. I use the date table to help me know when an event is old.

Member Avatar for diafol

how about saving as unix timestamp? You're duplicating data otherwise.
You can output data or search for a particular date with sql functions.

Thats true, But the question that im seeking an answer for is how do i re write this peice of code.

Where would I put the codes to check the database if this certain date has been input inside the database to change the color of backgound and make it a link to the events page and the url have a parameter with the date.

Such as

$mysql = mysql_query("SELECT * FROM events");

while($row = mysql_fetch_assoc($mysql))
{
$day = $row['day']; // This will pull the day
$year = $row['year'];
$month = $row['month'];
if($day == $d && $month == $m && $year == $y)//The $d refers to the date the calendar printed out with the For loop
{
   echo ''; //This can echo the change that needs to take place to show that there is something in the database for this date.
}
else
{
   echo ''; //The else can just do what it normally does..
{
}//End of while loop

Now that is just what i think needs to happen. But I need help arranging this.. Someone please help

Thanks

i also use jquery to display display the content if the user hover the dates.
- the date format that i used is
date('F-j-Y');
September-1-2011;
and then i explode it so if the $m==september-2011 {only records for september will displayed


if the $d==1 { only the content for this day will display}

}


so if the user click the next or the previous months .. all the dates from september will not be included.

<?php 
 $x=$_GET[x]; 
if($x=="") $x = date("n"); 

$y=date('Y'); - instead of 2006 i just change it to current year...
$date = strtotime($y."/$x/1"); 
$day = date("D",$date); 
$m = date("F-Y",$date);
 
$totaldays = date("t",$date); //get the total day of specified date 
$prev=$x - 1; 
$next = $x + 1; 
if($prev==0) $prev=1; 
if($next==13) $next = 12; 

?>
<centeR>
<div class="tabledate">
<div class="navdate"><a href = '?x=<?php echo $prev ?>' style="float:left;"> < </a><span ><?php echo $m;?></span><a href = '?x=<?php echo$next ?>' style="float:right;">> </a></div><br  class="clearfloat"/>

<div id="tblmenudate" >Sun</div><div id="tblmenudate" >Mon</div> <div id="tblmenudate" >Tue</div><div id="tblmenudate" >Wed</div> <div id="tblmenudate" >Thu</div> <div id="tblmenudate">Fri</div> <div id="tblmenudate">Sat</div>
 <br  class="clearfloat"/>


<?
if($day=="Sun") $st=1; 
if($day=="Mon") $st=2; 
if($day=="Tue") $st=3; 
if($day=="Wed") $st=4; 
if($day=="Thu") $st=5; 
if($day=="Fri") $st=6; 
if($day=="Sat") $st=7; 

if ($st >= 6 && $totaldays == 31) { 
$tl=42; 
}elseif($st == 7 && $totaldays == 30){ 
$tl = 42; 
}else{ 
$tl = 35; 
} 

$ctr = 1; 
$d=1; 
$now=date('d');
$today=date('F');


for($i=1;$i<=$tl;$i++){ 

if($ctr==1) echo " "; 

if($i >= $st && $d <= $totaldays){ 


if ($d==$today){

	
?>
<div id="rowmenudate" ><?php echo $d ?></div>
	<?php

	}
else {

	?>

<?


		
		
?>
<div id="rowmenudate" >
<?php

echo "<span style='text-align:right'>".$d."</span><br>";
 $gettotal=mysql_query("SELECT *,SUM(totalwork)FROM a_clients WHERE userid='$id' GROUP BY dateadded ") or die (mysql_error());
while ($rowtotal=mysql_fetch_array($gettotal)){
	$ex=explode("-", $rowtotal['dateadded']);

if ($ex[0]."-".$ex[2]==$m) {

	
	if($d==$ex[1]) {
		echo "<span style='color:blue;cursor:pointer;padding:50px;' class='showwork".$rowtotal['dateadded']."'>".$rowtotal['SUM(totalwork)']."</span>";
		 $showworkq=mysql_query("SELECT * FROM a_clients WHERE dateadded='".$rowtotal['dateadded']."' GROUP BY w_id"); 
	?>
     <div id="display<?php echo $rowtotal['dateadded']?>" class="displaywork"  >

    <?
	echo $rowtotal['dateadded']."<br>";
	while ($showr=mysql_fetch_array($showworkq)) {
		?>
        
       <?php echo $showr['c_name']?>- <?php echo $showr['totalwork'] ?><Br />
    <?php
		}
	?>
    <span class="pointer"><img src="images/display.png" /></span>
    </div>
          <script type="text/javascript">
$(".showwork<?php echo $rowtotal['dateadded'] ?>").mouseover(function () {
 $("#display<?php echo $rowtotal['dateadded'] ?>").show("drop", { direction: "down" }, 300);
  $("#display<?php echo $rowtotal['dateadded'] ?>").draggable();
});
$(".showwork<?php echo $rowtotal['dateadded'] ?>").mouseout(function () {
 $("#display<?php echo $rowtotal['dateadded'] ?>").hide("drop", { direction: "down" }, 300);

});

</script>
        
        
		<?php 
		
	}
}
	
	?>
 
<?php 

	}


	?>
</div>
    
    <?php
}
$d++; 
} 

else{ 
?>
<div id='rowmenudate' class="nodate">&nbsp;</div>
<?php
} 

$ctr++; 

if($ctr > 7) { 
$ctr=1; 
?>

<?php
} 

} 
}

?>

this that the css that i made.

.tabledate {
	

color:#666;
width:980px;
padding:2px;
padding-top:10px;
border:1px solid #CCC;
background:#F3F3F3;

	
	}
	

.pointer {
position:relative;
top:19px;
left:54px;
	}	
.navdate {
	
width:960px;
margin-top:-10px;
padding:10px;
	background:#69F;

	}	
.navdate a {
	
margin-top:10px;
color:#FFF;
font-weight:bolder;
font-size:20px;

padding:2px;
	}	
.navdate span{

 font-size:25px;
color:#FFF;
text-shadow:1px 1px 2px #333;
	}	

#tblmenudate, #rowmenudate, .currentdate  {
padding:8px;
	min-width:123px;
	float:left;
	text-align:center;
}
#rowmenudate, .currentdate {
	
	padding:8px;
	
	font-size:19px;
	color:#666;
	font-family:Georgia, "Times New Roman", Times, serif;
	min-width:124px;
	-moz-border-radius:6px;
	-webkit-box-shadow:inset 0 0 3px #FFF, 0 0 1px #69F;
	background:#DEEEF8;
	height:50px;

text-transform:capitalize;
	}
.nodate {
background:#CCC;
		-moz-border-radius:6px;
	-webkit-box-shadow:none;
	}	
	
.currentdate {
	color:#FFF;
	background:#69F;
	-webkit-box-shadow:inset 0 0 10px #4E86DA, 0 0 1px #FFF;
	-moz-box-shadow:inset 0 0 10px #4E86DA, 0 0 1px #FFF;
	}	
.displaywork {
	
	min-width:180px;
	padding:10px;
	font-size:13px;
	margin-top:-180px;
	z-index:300;
position:absolute;
	max-height:300px;
	display:none;
	background:#FC0;
	text-align:left;

	
	}		
#rowmenudate:hover {
	color:#000;
	
	}
Member Avatar for diafol

what's the point here mrtreb? Do you want help or are you posting a solution? I can't follow the code as you've not used [ CODE ] tags.

what's the point here mrtreb? Do you want help or are you posting a solution? I can't follow the code as you've not used [ CODE ] tags.

I'm sorry ardav I was just excited when i post the modified script that i made yesterday, i was looking for the answers too like him, but in the end just modified it myself and that is why i shared it here so he could use it. I would like to re post it using the CODE tag.

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.