Forum Moderators: coopster

Message Too Old, No Replies

Calendar Query

         

woldie

2:23 pm on Aug 25, 2004 (gmt 0)

10+ Year Member



Hi,

I'm having some trouble using a calender I've coded.

I have a form which you have to select a engineer, when you hit submit it brings up the calender. The trouble is, is that the calender displays the correct month but when I click next it won't go to the next month.

Any ideas?

Here's the code:

<?
// Check for a Month Change submission
if ($submit)
{
// Subtract one from the month for previous, add one for next
if ($submit == "Prev")
{
$month_now--;
}
else
{
$month_now++;
}

$date = getdate(mktime(0,0,0,$month_now,1,$year_now));

}
else
{
#echo 'hello12';
$date = getdate();
}

$month_num = $date["mon"];
$month_name = $date["month"];
$year = $date["year"];
$date_today = getdate(mktime(0,0,0,$month_num,1,$year));
$first_week_day = $date_today["wday"];
$cont = true;
$today = 27;

while (($today <= 32) && ($cont))
{
$date_today = getdate(mktime(0,0,0,$month_num,$today,$year));
if ($date_today["mon"]!= $month_num)
{
$lastday = $today - 1;
$cont = false;
}
$today++;
}

?>

<html>
<head>
<title>Booking System</title>
<link rel="stylesheet" type="text/css" href="_css/style-curr.css">
</head>

<body>
<div id="signup">
<form method="post" action="index.php">
<table>
<tr>
<td colspan="2"><h3>Company Information</h3></td>
</tr>
<tr>
<td class="labelcell"><label for="engineer">Engineer</label></td>
<td class="smallfieldcell">
<select name="engineer" class="smallfieldcell">
<option value="null">Select One</option>
<?

$result=mysql_query("select engineernum,firstname,surname
from cmsengineers");
while (list($DBengineernum,$DBfirstname,$DBsurname)=mysql_fetch_row($result))
{
echo "<option value=$DBengineernum>".$DBfirstname.' '.$DBsurname.'</option>';
}
?>
</select>
</tr>
<tr>
<?
$date = getdate();
$month_num = $date["mon"];
$month_name = $date["month"];
$year = $date["year"];
?>
<td colspan="2" align="center">
<input type="submit" name="submit" value="Submit" tabindex="2" class="button" />
<input type="hidden" name="month_num" value=<? echo $month_num?>>
<input type="hidden" name="month_name" value=<? echo $month_name?>>
<input type="hidden" name="year" value=<? echo $year?>>
<input type="hidden" name="date" value=<? echo $date?>>
</td>
</tr>
</table>
</form>

</div>

<?
if (isset($engineer) ¦¦ $stage==1)
{
echo 'hello';
?>
<!-- allow for form submission to the script for forward and backwards -->
<form action="index.php" method="POST" name="calendar">
<input type="hidden" name="month_now" value=<? echo $month_num?>>
<input type="hidden" name="year_now" value=<? echo $year?>>
<input type="hidden" name="stage" value=1>
<table width="200">
<tr>
<td><input type="submit" name="submit" value="Prev"></td>
<td align="right"><input type="submit" name="submit" value="Next"></td>
</tr>
</table>
</form>

<table width="160" border="1" cellspacing=0 cellpadding=2>
<tr>
<td colspan="7"><? echo $month_name . " " . $year?></td>
</tr>
<tr>
<td>Su</td>
<td>M</td>
<td>T</td>
<td>W</td>
<td>Th</td>
<td>F</td>
<td>Sat</td>
</tr>
<?
// begin placement of days according to their beginning weekday
$day = 1;
$wday = $first_week_day;
$firstweek = true;
while ($day <= $lastday)
{
if ($firstweek)
{
echo '<tr>';
for ($i=1; $i<=$first_week_day; $i++)
{
echo '<TD> </td>';
}
$firstweek = false;
}
if ($wday==0)
{
echo '<tr>';
}

// make each day linkable to the following result.php page
if (intval($month_num) < 10)
{
$new_month_num = "0$month_num";
}
elseif (intval($month_num) >= 10)
{
$new_month_num = $month_num;
}

if ( intval($day) < 10)
{
$new_day = "0$day";
}
elseif (intval($day) >= 10)
{
$new_day = $day;
}

$link_date = "$year-$new_month_num-$new_day";
echo "<td><a href=results.php?eventid=$link_date> $day </a></td>";

if ($wday==6)
{
echo '</tr>';
}

$wday++;
$wday = $wday % 7;
$day++;
}



}
?>
</body>
</html>

Thanks

:o)

woldie

4:41 pm on Aug 25, 2004 (gmt 0)

10+ Year Member



Hi,

I sussed it out, I've had to use a <iframe> tag so that it displays the correct month when you submit the form.

Thanks