Jump to content

adding data to a calender


Novodk

Recommended Posts

I got this calendar on my site and i made the dates clickable, but is it possible to make it so that when i click on the dates it opens a new site where it shows somthing like: 

ibTOWC9.jpg

<?php
$monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
?>
<?php
if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");
?>
<?php
$cMonth = $_REQUEST["month"];
$cYear = $_REQUEST["year"];
 
$prev_year = $cYear;
$next_year = $cYear;
$prev_month = $cMonth-1;
$next_month = $cMonth+1;
 
if ($prev_month == 0 ) {
    $prev_month = 12;
    $prev_year = $cYear - 1;
}
if ($next_month == 13 ) {
    $next_month = 1;
    $next_year = $cYear + 1;
}
?> 
<tr>
<td align="center">
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td colspan="7"><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></td>
</tr>
<tr>
<td align="center">M</td>
<td align="center">T</td>
<td align="center">O</td>
<td align="center">T</td>
<td align="center">F</td>
<td align="center">L</td>
<td align="center">S</td>
</tr>

<?php 
    $timestamp = mktime(0,0,0,$cMonth,1,$cYear);
    $maxday    = date("t",$timestamp);
    $thismonth = getdate ($timestamp);
    $startday  = $thismonth['wday'];
     
     
    $newdate = date('Y-m-j',$timestamp);
    $newdate = strtotime ( '-1 day' , strtotime ( $newdate ) ) ;
    $newdate = date('Y-m-j',$newdate);
    $today = date('j');
 
for ($i=0; $i<($maxday+$startday); $i++) {
 if(($i % 7) == 0 ){
  echo "<tr>";
 }
 if($i < $startday){
  echo ("<td class='cell_txt'> </td>");
 } else {
  if (($i - $startday + 1) == $today){
   echo ("<td class='cell_today'><a href='#'>".($i - $startday + 1)."</a></td>");
  } else {
   echo ("<td class='cell_txt'><a href='tftimer.php?day=". ($i - $startday + 1) . "&month=$cMonth&year=$cYear'>".($i - $startday + 1)."</a></td>");
  }
 }
 if(($i % 7) == 6 ) {
  echo "</tr>\n";
 }
}   
?>
</table>
</td>
</tr>

I hope someone can help  :)

Link to comment
https://forums.phpfreaks.com/topic/281499-adding-data-to-a-calender/
Share on other sites

You sure can; where are you stuck? If you're unsure how to get the date information once the link is clicked, perhaps the following will help:

http://php.net/manual/en/reserved.variables.get.php

 

That link was all i needed, thanks alot.

Now i got another problem, i want to be able to add data from my database to a dropdown menu, lets call the table "Table1" row "Name"

echo "<select name='username'>";
while ($row = mysql_fetch_array($result)) {
    echo "<option value='" . $row['username'] ."'>" . $row['username'] ."</option>";
}
echo "</select>";

That works fine, but if i want to add more data from another table called "Table2"  row "Age" how do i do that, i think my problem is how to setup my Recordset


<select name="Navn" id="Navn">
      <?php
do {  
?>
      <option value="<?php echo $row_timer['Navn']?>"><?php echo $row_timer['Navn']?></option>
      <?php
} while ($row_timer = mysql_fetch_assoc($timer));
  $rows = mysql_num_rows($timer);
  if($rows > 0) {
      mysql_data_seek($timer, 0);
 $row_timer = mysql_fetch_assoc($timer);
  }
?>
    </select>

Im using Dreamweaver and there is an automatic thing that adds that piece of code, it works okay, but it shows each entry from the database twice in the dropdown menu, anyone that can figure out why?

Archived

This topic is now archived and is closed to further replies.

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