Form not working...
-
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
-
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
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.