Jump to content

Onclick problem in a html form in my php script


lsedk

Recommended Posts

Sorry but this may seem as a minor thing - but I did not manage to get it to work

 

I'm trying to place two buttons on top of my calendar, one for going one month ahead and one going back. I believe I would have to have a Form and then extract information on the clicked one with the $_GET, but.... I wrote some functions and just want to activate the fundtion clicking one the buttons. But how?

 

 

<?php

       

        echo "<form method=\"get\">";

        echo "<input type=\"button\" name=\"prev\" onClick=\"history.go(0)\" value=\" << \" />";

        echo "<input type=\"button\" name=\"next\" onClick=\"history.go(0)\" value=\" >> \" />";

        echo "</form>";       

 

        // echo "her";

        // echo $_GET["prev"].value;

 

        $con  = mysql_connect("localhost","nbkw_dk","ni2aiaPB");

        mysql_select_db("nbkw_dk", $con);

 

        $date  = time();

$day  = date('d',$date);

$month = date('m',$date);

        $m    = date('m',$date);

$year  = date('y',$date);

        $found = "N";

       

        // $month = 11;

 

        function nextyear($year) { $year = $year + 1; return $year; }

        function prevyear($year) { $year = $year - 1; return $year; }

        function nextmonth($month)  {           

            if($month == 12)

                $month = 1;

            else           

                $month = $month + 1;

                       

            return $month;

        }

        function prevmonth($month) {           

            if($month == 1)

                $month = 12;

            else           

                $month = $month - 1;

                     

            return $month;

        }

               

        $m = $month;

        $month = nextmonth($month);

        if($m > $month)

            $year = nextyear($year);

                 

        $m = $month;

        $month = prevmonth($month);

        if($m < $month)

            $year = prevyear($year);

       

 

$first_day  = mktime(0,0,0,$month, 1, $year);

$title      = date('F',$first_day);

$day_of_week = date('D',$first_day);

       

        switch($day_of_week){

case "Sun": $blank = 0; break;

case "Mon": $blank = 1; break;

case "Tue": $blank = 2; break;

case "Wed": $blank = 3; break;

case "Thu": $blank = 4; break;

case "Fri": $blank = 5; break;

case "Sat": $blank = 6; break;

}

 

$days_in_month = cal_days_in_month(0, $month, $year);

 

        echo "<table border=6 width=394>";

echo "<tr><th colspen=60> $title $year </th>";

        echo "<tr><td width=62>Søn</td><td width=62>Man</td><td width=62>Tir</td><td width=62>Ons</td>

              <td width=62>Tor</td><td width=62>Fre</td><td width=62>Lør</td>";

        $day_count = 1;

echo "<tr>";

 

        while( $blank > 0 ){

echo "<td></td>";

$blank = $blank-1;

$day_count++;

 

        }

                         

        $day_num = 1;

 

        while( $day_num <= $days_in_month ){

       

                  $result    = null;

                  $dayselect = date("Y-m-d",mktime(0,0,0,$month,$day_num,$year));

                  $result    = mysql_query("SELECT * FROM Kalender WHERE (Type=2 OR Type=3) AND Startdato=DATE'$dayselect'",$con);

                 

                  $found = "N";

                  while($row = mysql_fetch_array($result))

                  {

                      if($row)

                      {

                          echo "<td style=\"background: #7dc473;color:green\"> <A href=\"/showkalenderdato.php?date=$day_num&month=$month&year=$year\" target=\"_blank\" > $day_num </A></td>";

                          $found = "Y";

                          break;

            }

                  }

 

                  if($found == "N")

                    echo "<td style=\"background: #cccccc\"> $day_num </td>";

                 

                  $day_num++;

        $day_count++;

 

        if( $day_count > 7 ){

          echo "</tr><tr>";

              $day_count = 1;

        }

}

       

echo "</tr></table>";   

 

   

?>

 

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.