这是我的日历看起来的样子.. 我已经使用function.calender创建了日历工作正常但现在我想要禁用它的星期六和星期日列。我怎么能这样做?
提前致谢。
我试过下面的代码。
function draw_calendar($month,$year){
if($month=='1')
{
$strmonth='january';
}
else if($month=='2')
{
$strmonth='february';
}
else if($month=='3')
{
$strmonth='march';
}
else if($month=='4')
{
$strmonth='april';
}
else if($month=='5')
{
$strmonth='may';
}
else if($month=='6')
{
$strmonth='june';
}
else if($month=='7')
{
$strmonth='july';
}
else if($month=='8')
{
$strmonth='august';
}
else if($month=='9')
{
$strmonth='september';
}
else if($month=='10')
{
$strmonth='october';
}
else if($month=='11')
{
$strmonth='november';
}
else if($month=='12')
{
$strmonth='december';
}
/* draw table */
$calendar = '<table cellpadding="0" cellspacing="0" class="calendar" align="center" ><tr><td align="center" colspan="7" style="border:1px solid gray;text-transform:uppercase;border-left:none;color:chocolate;height:30px;font-size:30px;padding:5px;"><b>'.$strmonth.' '.$year.'</b></td></tr>';
/* table headings */
$headings = array('<font color="red">Sunday</font>','Monday','Tuesday','Wednesday','Thursday','Friday','<font color="red">Saturday</font>');
$calendar.= '<tr class="calendar-row"><td class="calendar-day-head">'.implode('</td><td class="calendar-day-head">',$headings).'</td></tr>';
/* days and weeks vars now ... */
$running_day = date('w',mktime(0,0,0,$month,1,$year));
$days_in_month = date('t',mktime(0,0,0,$month,1,$year));
$days_in_this_week = 1;
$day_counter = 0;
$dates_array = array();
/* if(($headings[0]))
{
$sday='style="color:red"';
}
else
{
$sday='style="color:gray"';
}
*/
/* row for week one */
$calendar.= '<tr class="calendar-row" >';
/* print "blank" days until the first of the current week */
for($x = 0; $x < $running_day; $x++):
$calendar.= '<td class="calendar-day-np" > </td>';
$days_in_this_week++;
endfor;
/* keep going with days.... */
for($list_day = 1; $list_day <= $days_in_month; $list_day++):
if(isset($_SESSION['client']) && !empty($_SESSION['client']))
{
$s="select * from tbl_job_schedule where jobdate='".$strmonth."-".$list_day."-".$_SESSION['yy']."' and clientname='".$_SESSION['client']."'";
$q=mysql_query($s) or die($s);
$rw=mysql_fetch_array($q);
}
else if(isset($_SESSION['user']) && !empty($_SESSION['user']))
{
$s="select * from tbl_job_schedule where jobdate='".$strmonth."-".$list_day."-".$_SESSION['yy']."' and username='".$_SESSION['user']."'";
$q=mysql_query($s) or die($s);
$rw=mysql_fetch_array($q);
}
if($rw['status']=='schedule')
{
$strimg='<img src="images/schedule.png" height="35" width="35"/>';
}
else if($rw['status']=='schwork')
{
$strimg='<img src="images/schedule.png" height="35" width="35"/> <img src="images/work.png" height="35" width="35"/>';
}
else if($rw['status']=='schworkcmnt' && $rw['client_cmnt']=='')
{
$strimg='<img src="images/schedule.png" height="35" width="35"/> <img src="images/work.png"height="35" width="35" />';
}
else if($rw['status']=='schworkcmnt' && $rw['client_cmnt']!='')
{
$strimg='<img src="images/schedule.png" height="35" width="35"/> <img src="images/work.png" height="35" width="35"/><br><img src="images/cmnt.png" height="35" width="35"/>';
}
else
{
$strimg='';
}
$calendar.= '<td class="calendar-day" onClick="OpenWin('.$list_day.');" >';
$calendar.= '<div class="day-number" >'.$list_day.'</div><div style="height:90px;width:80px;border:0px solid yellow;float:right;padding-right:0px;padding-top:10px;" >'.$strimg.'</div><div style="height:40px;width:150px;padding:0px;border:0px solid yellow;float:left;margin-top:50px;margin-right:20px;font-size:14px;color:gray;text-transform:capitalize;" ><b>'.$rw['client_comp'].'</b></div>';
/** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM !! **/
$calendar.= str_repeat('<p> </p>',2);
$calendar.= '</td>';
if($running_day == 6):
$calendar.= '</tr>';
if(($day_counter+1) != $days_in_month):
$calendar.= '<tr class="calendar-row">';
endif;
$running_day = -1;
$days_in_this_week = 0;
endif;
$days_in_this_week++; $running_day++; $day_counter++;
endfor;
/* finish the rest of the days in the week */
if($days_in_this_week < 8):
for($x = 1; $x <= (8 - $days_in_this_week); $x++):
$calendar.= '<td class="calendar-day-np"> </td>';
endfor;
endif;
/* final row */
$calendar.= '</tr>';
/* end the table */
$calendar.= '</table>';
/* all done, return result */
return $calendar;
}
/* sample usages */
?>
答案 0 :(得分:0)
试试这个:
//all other code. Check if date of the week equals 0-sunday or 6-saturday
if($running_day==0 || $running_day==6) {
$calendar.= '<td> </td>';
}
else
{
$calendar.= '<td class="calendar-day" onClick="OpenWin('.$list_day.');" >';
//... all other code
$calendar.= '</td>';
}
注意:代码未经过测试。