UBB.Dev
Posted By: poil Calendar script, please help - 01/20/2001 9:46 PM
can anyone give me some help on php? i am trying to make a calendar to use with wwwthreads to show birthdays for the users. i am able to show one birthday for each month but not able to show multiple birthdays for each month. can anyone take a peep at my script and see whats up? thanks in advance!



<?
require ("main.inc.php");
$Username = $w3t_myname;
$Password = $w3t_mypass;
$html = new html;
$html -> send_header($config['title'],$Cat,0,$user['U_Username'],$user['U_Password'],0,$user);


// get all the info
if (!$HTTP_POST_VARS) {
$theDate = getdate();
$mon = $theDate["mon"]; // numeric month (1-12)
$month = $theDate["month"]; // display month january, feb..
$year = $theDate["year"]; // 4 digit year (y2k compliant)
}
if ($action = "findDate") {
$theDate = getdate(mktime(0,0,0,$mon,1,$year));
$month = $theDate["month"];
}


// get what weekday the first is on
$tempDate = getdate(mktime(0,0,0,$mon,1,$year));
$firstwday= $tempDate["wday"];

// get the last day of the month
$cont = true;
$tday = 27;
while (($tday <= 32) && ($cont)) {
$tdate = getdate(mktime(0,0,0,$mon,$tday,$year));
if ($tdate["mon"] != $mon) {
$lastday = $tday - 1;
$cont = false;
}
$tday++;
}

?>

<table width="95%" border="0" align="center">
<tr>
<TD ALIGN="CENTER">
<? echo " <b>$month $year</b> "; ?>
</TD>
</tr>
</table>

<table width="95%" border="2" cellspacing=0 cellpadding=2 bordercolor="#000000" align="center">
<tr class="darktable"><th>Sunday</th><th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th><th>Saturday</th></tr>
<? $d = 1;
$thisDay = date('d');
$thisMon = date('n');
$thisMonth = date('F');
$thisYear = date('Y');
$wday = $firstwday;
$firstweek = true;
$query = "
SELECT U_Extra3,U_Extra4,U_Username
FROM w3t_Users
WHERE U_Extra3 = '$mon'
";
$sth = $dbh -> do_query($query);
$birthday = $dbh -> total_rows($sth);
list ($Month,$Date,$Username_p) = $dbh -> fetch_array($sth);
// loop through all the days of the month
while ( $d <= $lastday) {

// set up blank days for first week
if ($firstweek) {
echo "<TR>";
for ($i=1; $i<=$firstwday; $i++) {
echo "<TD> </td>";
}
$firstweek = false;
}


if ($wday==0) {
// Sunday start week with <tr>
echo "<tr>";
}
// print cell
//
echo "<td height="51" valign="top" align="left" width ="14%" class="lighttable">$d.
";
if ($d == $Date)
{

for( $j=0 ; $j <=$birthday ; $j++ ) {
echo "<a href="http://www.extremeforums.org/showprofile.php?Cat=&User=$Username_p">$Username_p's Birthday.</a>";
}
}
else
{
echo " ";
}
echo "</td>";


if ($wday==6) {
// Saturday end week with </tr>
echo "</tr>\n";
}


$wday++;
$wday = $wday % 7;
$d++;
$dbh -> finish_sth($sth);

}

?>
<TR><TD COLSPAN="7" ALIGN="CENTER">Today is <? $dte=date("l, M j, Y"); echo $dte; ?></TD></TR>
<TR bgcolor="navy"><TD COLSPAN="7" ALIGN="CENTER" class="tdheader"><FORM METHOD="POST" ACTION="<? echo $PHP_SELF; ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="findDate">
<BR>
Go To:
<SELECT NAME="mon">
<OPTION VALUE="<? echo $thisMon; ?>"><? echo $thisMonth; ?></OPTION>
<OPTION VALUE="<? echo $thisMon; ?>">--------------</OPTION>
<OPTION VALUE="1">January</OPTION>
<OPTION VALUE="2">February</OPTION>
<OPTION VALUE="3">March</OPTION>
<OPTION VALUE="4">April</OPTION>
<OPTION VALUE="5">May</OPTION>
<OPTION VALUE="6">June</OPTION>
<OPTION VALUE="7">July</OPTION>
<OPTION VALUE="8">August</OPTION>
<OPTION VALUE="9">September</OPTION>
<OPTION VALUE="10">October</OPTION>
<OPTION VALUE="11">November</OPTION>
<OPTION VALUE="12">December</OPTION>
</SELECT>
<SELECT NAME="year">
<OPTION VALUE="<? echo $thisYear; ?>"><? echo $thisYear; ?></OPTION>
<OPTION VALUE="<? echo $thisYear; ?>">--------</OPTION>
<OPTION VALUE="2000">2000</OPTION>
<OPTION VALUE="2001">2001</OPTION>
<OPTION VALUE="2002">2002</OPTION>
<OPTION VALUE="2003">2003</OPTION>
<OPTION VALUE="2004">2004</OPTION>
<OPTION VALUE="2005">2005</OPTION>
</SELECT>
<INPUT TYPE="Submit" VALUE="Find!">
</FORM></TD></TR>
</table>
<?
$html -> send_footer();
?>


[:red]--------------
http://extremeforums.org/index

Attached File
28953-calendar.php.txt  (10 downloads)
Posted By: poil Re: Calendar script, please help - 01/25/2001 7:45 PM
any help with this?

[:red]--------------
http://extremeforums.org/index
Posted By: Rick Re: Calendar script, please help - 01/26/2001 5:01 PM
What happens when this is run? Does it die, or does it finish printing out the month but only with the 1 birthday in it?

-------------------
Scream
WWWThreads
Posted By: poil Re: Calendar script, please help - 01/26/2001 6:04 PM
yeah it prints out everything and then it displays every birthday in one day. example http://extremeforums.org/calendar2.php i don't know if or how it can be done, but it needs to do a while if statement while in another while statement.but then it needs to do it again for if there are multiple birthdays. thanks....

[:red]--------------
http://extremeforums.org/index
Posted By: Rick Re: Calendar script, please help - 01/31/2001 6:21 AM
I think there are 2 ways you could solve this problem. You could either execute the query to see if there are any birthdays on that particular day within the loop where you are printing out the days. That means a query for each day.

Or, you could grab all birthdays within the month and stuff them into an array of some sort that keys off of the day and then when printing out each day you could check the array.

Sorry I can't be of much more help. Kinda tough to figure out what to do without having it to work on. Though it does look like a pretty cool addition.
Posted By: poil Re: Calendar script, please help - 04/06/2001 10:54 PM
found out the problem, i was thinking wrong.... http://www.extremeforums.org/calendar.php?Cat=

[:red]--------------
http://extremeforums.org
© UBB.Developers