Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. Form not working...

Form not working...

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phphelp
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MacRaider4
    wrote on last edited by
    #1

    Ok been working on this for about 2 hours and I'm officially stuck. What I'm trying to do is bild a calendar (got that part working how I want) where I can change the month. I have the following code:

    function startTable2($currentMonth,$currentYear) {
    //retreive the value of $currentMonth by name
    $month = date("F", mktime(0,0,0, date($currentMonth), date("t"), date($currentYear)));
    echo "<table border=1 align=\"center\">";
    echo "<form action=\"Calendar2.php\" method=\"post\">";
    echo "<tr>";
    echo "<td align=\"left\"><input type=\"submit\" name=\"previous\" id=\"previous\" value=\"Previous Month\" />";
    if ($currentMonth == 1) {
    $currentYear = $currentYear - 1;
    $currentMonth = 12;
    }
    else
    {
    $currentMonth = date("m", mktime(0,0,0, date($currentMonth)-1, date("1"), date($currentYear)));
    }
    echo "<input type=\"hidden\" name=\"month\" id=\"month\" value=$currentMonth /></td>";
    echo "<input type=\"hidden\" name=\"year\" id=\"year\" value=$currentYear /></td>";
    echo "<input type=\"hidden\" name=\"day\" id=\"day\" value=\"01\" /></td>";
    echo "</form>";
    echo "<td colspan=5 align=center>$month $currentYear</td>";
    echo "<form action=\"Calendar3.php\" method=\"post\">";
    if ($currentMonth == 12) {
    $currentYear = $currentYear + 1;
    $currentMonth = 1;//date("m", mktime(0,0,0, date("1"), date("1"), date($currentYear)));
    }
    else
    {
    //$newDate = mktime(0,0,0, date($currentMonth)+1, date("1"), date($currentYear));
    $currentMonth = date("m", mktime(0,0,0, date($currentMonth)+1, date("1"), date($currentYear)));//date('m', $newDate);
    }
    echo "<td align=\"right\"><input type=\"submit\" name=\"next\" id=\"next\" value=\"Next Month\" />";
    echo "<input type=\"hidden\" name=\"month1\" id=\"month1\" value=$currentMonth /></td>";
    echo "<input type=\"hidden\" name=\"year1\" id=\"year1\" value=$currentYear /></td>";
    echo "<input type=\"hidden\" name=\"day1\" id=\"day1\" value=\"01\" /></td>";
    echo "</td></form></tr>";
    echo "<tr><td align=center>Sunday</td><td align=center>Monday</td><td align=center>Tuesday</td><td align=center>Wednesday</td><td align=center>Thursday</td><td align=center>Friday</td><td align=center>Saturday</td></tr>";
    }

    As of now the "previous" works for every other month (i.e. December, Octobe

    M 1 Reply Last reply
    0
    • M MacRaider4

      Ok been working on this for about 2 hours and I'm officially stuck. What I'm trying to do is bild a calendar (got that part working how I want) where I can change the month. I have the following code:

      function startTable2($currentMonth,$currentYear) {
      //retreive the value of $currentMonth by name
      $month = date("F", mktime(0,0,0, date($currentMonth), date("t"), date($currentYear)));
      echo "<table border=1 align=\"center\">";
      echo "<form action=\"Calendar2.php\" method=\"post\">";
      echo "<tr>";
      echo "<td align=\"left\"><input type=\"submit\" name=\"previous\" id=\"previous\" value=\"Previous Month\" />";
      if ($currentMonth == 1) {
      $currentYear = $currentYear - 1;
      $currentMonth = 12;
      }
      else
      {
      $currentMonth = date("m", mktime(0,0,0, date($currentMonth)-1, date("1"), date($currentYear)));
      }
      echo "<input type=\"hidden\" name=\"month\" id=\"month\" value=$currentMonth /></td>";
      echo "<input type=\"hidden\" name=\"year\" id=\"year\" value=$currentYear /></td>";
      echo "<input type=\"hidden\" name=\"day\" id=\"day\" value=\"01\" /></td>";
      echo "</form>";
      echo "<td colspan=5 align=center>$month $currentYear</td>";
      echo "<form action=\"Calendar3.php\" method=\"post\">";
      if ($currentMonth == 12) {
      $currentYear = $currentYear + 1;
      $currentMonth = 1;//date("m", mktime(0,0,0, date("1"), date("1"), date($currentYear)));
      }
      else
      {
      //$newDate = mktime(0,0,0, date($currentMonth)+1, date("1"), date($currentYear));
      $currentMonth = date("m", mktime(0,0,0, date($currentMonth)+1, date("1"), date($currentYear)));//date('m', $newDate);
      }
      echo "<td align=\"right\"><input type=\"submit\" name=\"next\" id=\"next\" value=\"Next Month\" />";
      echo "<input type=\"hidden\" name=\"month1\" id=\"month1\" value=$currentMonth /></td>";
      echo "<input type=\"hidden\" name=\"year1\" id=\"year1\" value=$currentYear /></td>";
      echo "<input type=\"hidden\" name=\"day1\" id=\"day1\" value=\"01\" /></td>";
      echo "</td></form></tr>";
      echo "<tr><td align=center>Sunday</td><td align=center>Monday</td><td align=center>Tuesday</td><td align=center>Wednesday</td><td align=center>Thursday</td><td align=center>Friday</td><td align=center>Saturday</td></tr>";
      }

      As of now the "previous" works for every other month (i.e. December, Octobe

      M Offline
      M Offline
      MacRaider4
      wrote on last edited by
      #2

      I've made some code changes and the next no longer comes up blank, it's not right but it's not blank... I also tried to make it more readable.

      function startTable2($currentMonth,$currentYear) {
      //retreive the value of $currentMonth by name
      $month = date("F", mktime(0,0,0, date($currentMonth), date("t"), date($currentYear)));
      $year = $currentYear;
      echo "<table border=1 align=\"center\">";
      echo "<tr>";
      echo "<td align=\"left\">";
      echo "<form action=\"Calendar2.php\" method=\"post\">";
      echo "<input type=\"submit\" name=\"previous\" id=\"previous\" value=\"Previous Month\" />";
      if ($currentMonth == 1) {
      $currentYear = $currentYear - 1;
      $currentMonth = 12;
      }
      else
      {
      $currentMonth = date("m", mktime(0,0,0, date($currentMonth)-1, date("1"), date($currentYear)));
      }
      echo "<input type=\"hidden\" name=\"month\" id=\"month\" value=$currentMonth />";
      echo "<input type=\"hidden\" name=\"year\" id=\"year\" value=$currentYear />";
      echo "<input type=\"hidden\" name=\"day\" id=\"day\" value=\"01\" />";
      echo "</form>";
      echo "</td>";
      echo "<td colspan=5 align=center>$month $year";
      echo "</td>";
      echo "<td align=\"right\">";
      echo "<form action=\"Calendar3.php\" method=\"post\">";
      echo "<input type=\"submit\" name=\"next\" id=\"next\" value=\"Next Month\" />";
      if ($currentMonth == 12) {
      $currentYear = $currentYear + 1;
      //$currentMonth = 1;//date("m", mktime(0,0,0, date("1"), date("1"), date($currentYear)));
      }
      else
      {
      $currentMonth = $currentMonth + 1;
      }
      echo "<input type=\"hidden\" name=\"month1\" id=\"month1\" value=$currentMonth />";
      echo "<input type=\"hidden\" name=\"year1\" id=\"year1\" value=$currentYear />";
      echo "<input type=\"hidden\" name=\"day1\" id=\"day1\" value=\"01\" />";
      echo "</form>";
      echo "</td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td align=center>Sunday</td><td align=center>Monday</td><td align=center>Tuesday</td><td align=center>Wednesday</td><td align=center>Thursday</td><td align=center>Friday</td><td align=center>Saturday</td>";
      echo "</tr>";
      // Table ends in another function
      }

      hope that helps a little.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups