piznac Posted November 15, 2006 Share Posted November 15, 2006 Hey guys,.. I found a tutorial for doing a calendar script but Im having a hard to changing it to fit my needs. This script list out all the days in a month then stores events in a db. What I want is on the main page of the calendar to display icons when there are events in the db for that date.[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";[/quote]I tried to add this with no luck:[quote]$dates = explode(' ' , $link_date);foreach ($dates as $value){mysql_select_db("rack_pm",$pms); $sql = "SELECT * from subjob where sdate = '$value'";$result = mysql_query($sql, $pms) or die (mysql_error()); if($results == ''){echo "Not much here boss";}else{echo "icon";}}[/quote]and here's the rest of the script:[quote]echo "<td align=left valign=top> <a href=results.php?if ($wday==6) { echo "</tr>\n"; } $wday++; $wday = $wday % 7; $day++; } echo" </table>";?>[/quote]As normal Im pretty lost here,. any help would be grand Link to comment https://forums.phpfreaks.com/topic/27333-help-with-calendar-script/ Share on other sites More sharing options...
piznac Posted November 15, 2006 Author Share Posted November 15, 2006 bump ;D Link to comment https://forums.phpfreaks.com/topic/27333-help-with-calendar-script/#findComment-125100 Share on other sites More sharing options...
piznac Posted November 16, 2006 Author Share Posted November 16, 2006 one more again Bump Link to comment https://forums.phpfreaks.com/topic/27333-help-with-calendar-script/#findComment-125548 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.