piznac Posted November 27, 2006 Share Posted November 27, 2006 I know I have asked this before but I havent gotten an answer and I have narrowed it down a bit (I think :))...I have a calendar script here:[quote]<?php // 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 { $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++; } // allow for form submission to the script for forward and backwards echo" <form action=\"cal.php\" method=\"POST\" name=\"calendar\"> <input type=\"hidden\" name=\"month_now\" value=\"$month_num\"> <input type=\"hidden\" name=\"year_now\" value=\"$year\"> <table width=758> <tr><td width=\"144\"><input type=\"submit\" name=\"submit\" value=\"Prev\"></td> <td width=\"454\" align=right><div align=\"center\">$month_name $year</div></td> <td width=\"144\" align=right><input type=\"submit\" name=\"submit\" value=\"Next\"></td> </tr> </table> </form> <table width=\"800\" border=\"1\" cellspacing=0 cellpadding=0 bordercolor=#000000 bgcolor=#999999 class=bor> <tr><td width=317 bgcolor=#000000><span class=style1>Sunday</span></td><td width=317 bgcolor=#000000><span class=style1>Monday</span></td><td width=317 bgcolor=#000000><span class=style1>Tuesday</span></td><td width=317 bgcolor=#000000><span class=style1>Wednesday </span></td><td width=317 bgcolor=#000000><span class=style1>Thursday</span></td><td width=317 bgcolor=#000000><span class=style1>Friday</span></td><td width=317 bgcolor=#000000><span class=style1>Saturday</span></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 height=60>"; for ($i=1; $i<=$first_week_day; $i++) { echo "<TD align=left valign=top> </td>"; } $firstweek = false; } if ($wday==0) { echo "<tr height=60>"; } // 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";$dates = explode(' ' , $link_date);foreach ($dates as $key => $value){mysql_select_db("rack_pm",$pms) or die (mysql_error()); $icon = "SELECT * from subjob where sdate = '$value'";$icon2 = mysql_query($icon, $pms) or die (mysql_error());$row_icon2 = mysql_fetch_array($icon2);if (($row_icon2['sdate'] == $value)){$icon1 = "<a href=\"cal3_results.php?id=$num\"><img src=\"http://project.rackattackzone.com/images/app.jpg\" width=\"18\" height=\"18\" /></a>";}else{$icon1 = '';}//check for miscif ($row_icon2['sdate'] == $value ){$icon333 = "<a href=\"cal3_results.php?id=$num\"><img src=\"http://project.rackattackzone.com/images/misc.jpg\" width=\"18\" height=\"18\" /></a>";}else{$icon333 = '';}//check for projectif ($row_icon2['sdate'] == $value){$icon334 = "<a href=\"cal3_results.php?id=$num\"><img src=\"http://project.rackattackzone.com/images/pro.jpg\" width=\"18\" height=\"18\" /></a>";}else{$icon334 = '';}}echo "<td align=left valign=top> <a href=results.php?eventid=$link_date>$day</a> $icon1 $icon333 $icon334 $type</td>"; if ($wday==6) { echo "</tr>\n"; } $wday++; $wday = $wday % 7; $day++; } echo" </table>";?>[/quote]Ok my question before was how to get it to echo "something" when there was an event in the DB on the actual calendar. Ok I got that working. But in that same DB I have "event types" like Appointment, Project,..etcWhat I need now is to look at that field as well and display an icon for that particular type of event.It comes down to this point (I think):[quote]link_date = "$year-$new_month_num-$new_day";$dates = explode(' ' , $link_date);foreach ($dates as $key => $value){mysql_select_db("rack_pm",$pms) or die (mysql_error()); $icon = "SELECT * from subjob where sdate = '$value'";$icon2 = mysql_query($icon, $pms) or die (mysql_error());$row_icon2 = mysql_fetch_array($icon2);if (($row_icon2['sdate'] == $value)){$icon1 = "<a href=\"cal3_results.php?id=$num\"><img src=\"http://project.rackattackzone.com/images/app.jpg\" width=\"18\" height=\"18\" /></a>";}else{$icon1 = '';}//check for miscif ($row_icon2['sdate'] == $value ){$icon333 = "<a href=\"cal3_results.php?id=$num\"><img src=\"http://project.rackattackzone.com/images/misc.jpg\" width=\"18\" height=\"18\" /></a>";}else{$icon333 = '';}//check for projectif ($row_icon2['sdate'] == $value){$icon334 = "<a href=\"cal3_results.php?id=$num\"><img src=\"http://project.rackattackzone.com/images/pro.jpg\" width=\"18\" height=\"18\" /></a>";}else{$icon334 = '';}}echo "<td align=left valign=top> <a href=results.php?eventid=$link_date>$day</a> $icon1 $icon333 $icon334 $type</td>"; [/quote] Ive tried just about anything I could think of,.. if I use a while loop to go thru the query results it screws up the other function. I have also tried this[quote]if (($row_icon2['sdate'] == $value) && ($row_icon2['type'] == "misc")){$icon1 = "<a href=\"cal3_results.php?id=$num\"><img src=\"http://project.rackattackzone.com/images/app.jpg\" width=\"18\" height=\"18\" /></a>";}else{$icon1 = '';}[/quote]that would work great IF thier was only one event type for the given date. That is not the case.. Im lost,.. If I need to explain PLEASE tell me,.. I really need some help on this one,.. thanks Link to comment https://forums.phpfreaks.com/topic/28647-calendar-problem/ Share on other sites More sharing options...
kenrbnsn Posted November 27, 2006 Share Posted November 27, 2006 Please don't use the [nobbc][quote][/quote][/nobbc] tags when posting your code. Use the [b][nobbc][code][/code][/nobbc][/b] tags. Those tags make the code much easier to read.Ken Link to comment https://forums.phpfreaks.com/topic/28647-calendar-problem/#findComment-131094 Share on other sites More sharing options...
piznac Posted November 27, 2006 Author Share Posted November 27, 2006 oh ok,.. is that why the color codes do not show up?[code]<?php // 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 { $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++; } // allow for form submission to the script for forward and backwards echo" <form action=\"cal.php\" method=\"POST\" name=\"calendar\"> <input type=\"hidden\" name=\"month_now\" value=\"$month_num\"> <input type=\"hidden\" name=\"year_now\" value=\"$year\"> <table width=758> <tr><td width=\"144\"><input type=\"submit\" name=\"submit\" value=\"Prev\"></td> <td width=\"454\" align=right><div align=\"center\">$month_name $year</div></td> <td width=\"144\" align=right><input type=\"submit\" name=\"submit\" value=\"Next\"></td> </tr> </table> </form> <table width=\"800\" border=\"1\" cellspacing=0 cellpadding=0 bordercolor=#000000 bgcolor=#999999 class=bor> <tr><td width=317 bgcolor=#000000><span class=style1>Sunday</span></td><td width=317 bgcolor=#000000><span class=style1>Monday</span></td><td width=317 bgcolor=#000000><span class=style1>Tuesday</span></td><td width=317 bgcolor=#000000><span class=style1>Wednesday </span></td><td width=317 bgcolor=#000000><span class=style1>Thursday</span></td><td width=317 bgcolor=#000000><span class=style1>Friday</span></td><td width=317 bgcolor=#000000><span class=style1>Saturday</span></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 height=60>"; for ($i=1; $i<=$first_week_day; $i++) { echo "<TD align=left valign=top> </td>"; } $firstweek = false; } if ($wday==0) { echo "<tr height=60>"; } // 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";$dates = explode(' ' , $link_date);foreach ($dates as $key => $value){mysql_select_db("rack_pm",$pms) or die (mysql_error()); $icon = "SELECT * from subjob where sdate = '$value'";$icon2 = mysql_query($icon, $pms) or die (mysql_error());$row_icon2 = mysql_fetch_array($icon2);if (($row_icon2['sdate'] == $value)){$icon1 = "<a href=\"cal3_results.php?id=$num\"><img src=\"http://project.rackattackzone.com/images/app.jpg\" width=\"18\" height=\"18\" /></a>";}else{$icon1 = '';}//check for miscif ($row_icon2['sdate'] == $value ){$icon333 = "<a href=\"cal3_results.php?id=$num\"><img src=\"http://project.rackattackzone.com/images/misc.jpg\" width=\"18\" height=\"18\" /></a>";}else{$icon333 = '';}//check for projectif ($row_icon2['sdate'] == $value){$icon334 = "<a href=\"cal3_results.php?id=$num\"><img src=\"http://project.rackattackzone.com/images/pro.jpg\" width=\"18\" height=\"18\" /></a>";}else{$icon334 = '';}}echo "<td align=left valign=top> <a href=results.php?eventid=$link_date>$day</a> $icon1 $icon333 $icon334 $type</td>"; if ($wday==6) { echo "</tr>\n"; } $wday++; $wday = $wday % 7; $day++; } echo" </table>";?>[/code]AHHHH HA,.. thanks Ken Ive been wondering about that Link to comment https://forums.phpfreaks.com/topic/28647-calendar-problem/#findComment-131100 Share on other sites More sharing options...
piznac Posted November 27, 2006 Author Share Posted November 27, 2006 *bumb* :-\ Link to comment https://forums.phpfreaks.com/topic/28647-calendar-problem/#findComment-131183 Share on other sites More sharing options...
piznac Posted November 28, 2006 Author Share Posted November 28, 2006 bump Link to comment https://forums.phpfreaks.com/topic/28647-calendar-problem/#findComment-131518 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.