Previous Thread
Next Thread
Print Thread
Rate Thread
#207689 01/20/2001 2:46 PM
Joined: Aug 2000
Posts: 262
Enthusiast
Enthusiast
Offline
Joined: Aug 2000
Posts: 262
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
Attachments
28953-calendar.php.txt (0 Bytes, 10 downloads)

Sponsored Links
Joined: Aug 2000
Posts: 262
Enthusiast
Enthusiast
Offline
Joined: Aug 2000
Posts: 262
any help with this?

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

Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
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


UBB.threads Developer
Joined: Aug 2000
Posts: 262
Enthusiast
Enthusiast
Offline
Joined: Aug 2000
Posts: 262
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

Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
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.


UBB.threads Developer
Sponsored Links
Joined: Aug 2000
Posts: 262
Enthusiast
Enthusiast
Offline
Joined: Aug 2000
Posts: 262
found out the problem, i was thinking wrong.... http://www.extremeforums.org/calendar.php?Cat=

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


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
JAISP
JAISP
PA
Posts: 449
Joined: February 2008
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)