需要循环帮助(我应该使用哪个循环来比较日期) [英] Need help with loops (which loop should i use to compare dates)

查看:58
本文介绍了需要循环帮助(我应该使用哪个循环来比较日期)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi

还要感谢所有在这里帮助过我的人... AlbinAbel和jswolf19 ...
非常感谢...

这是我想出的,到目前为止,它的工作原理...但是我还有一点要问...我该如何检查周末...
我在数据库中有一个周末的表名,它有两个字段,分别是天和类型
一天是从1到7,代表星期一至星期日和其他字段类型,可以由管理员为周末设置,无论管理员希望将哪一天设为周末...

如何查看由管理员设置的周末显示...背景颜色

hi

and thanks too all people who helped me here ...AlbinAbel and jswolf19...
thanks a lot...

this is what i came up with and so far its working ...but i have a little thing to ask ...how i can check weekend ...
i have a table name weekends in database and it have two field one for day and type
day is from 1-7 representing mon-sun and other field type which can be set by admin for weekends whatever day admin likes to be as weekend ...

how i can check display as weekend which are set by admin...with background color

<pre lang="xml"><table >
<?php
while ($row = mysql_fetch_array($rest, MYSQL_NUM)) {
    $request_id      = $row[1];
    $leave_status    = $row[2];
    $leave_comments  = $row[3];
    $leave_demp      = $row[4];
    $leave_type_name = $row[5];
    $leave_color     = $row[6];
    $emp_dep         = $row[7];
    $dbD = date("d", strtotime($row[0]));
    $dbM = date("m", strtotime($row[0]));
    $dbY = date("Y", strtotime($row[0]));
    $dbuser = date("Y-m-d", mktime(0, 0, 0, $dbM, $dbD, $dbY));
    $userDates[$dbuser] = array(''comments'' => $leave_comments, ''status'' => $leave_status,''color'' => $leave_color,''empdep'' => $emp_dep);
}
$cYear=2011;
$Months = array(1, 2, 3, 4,5,6,7,8,9,10,11,12);
$monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
foreach($Months as $M) { ?>
<tr>
<td width="18%" colspan="2"><strong><?php echo $monthNames[$M-1]; ?></strong></td>
<td width="12%" colspan="2"><strong><?php echo $userDates[$dbuser][''empdep''] ?></strong></td>
<?php
    $num = cal_days_in_month(CAL_GREGORIAN, $M, $cYear); // 31
    $arrydats = array_fill (1,$num,"");
    $i=0;
                foreach($arrydats as $d)
                {
                    $i++;
                    $dates = date("Y-m-d", mktime(0, 0, 0, $M,$i, $cYear));
                    $checkdate = strtotime($dates);
                                 if(isset($userDates[$dates]))
                                   {
                                    echo "<td  width=''26'' title=''".$userDates[$dates][''comments'']."'' height=''20px'' bgcolor=''#".$userDates[$dates][''color'']."'' align=''center'' valign=''middle'' >";
                                    if($userDates[$dates][''status''] == -1)
                                        { echo "R"; }
                                    elseif ($userDates[$dates][''status''] == 0 )
                                        { echo "C"; }
                                    elseif ($userDates[$dates][''status''] == 1 )
                                        { echo "PA"; }
                                    elseif ($userDates[$dates][''status''] == 2 )
                                        { echo "A"; }
                                    elseif ($userDates[$dates][''status''] == 3 )
                                        { echo "T"; }
                                    elseif ($userDates[$dates][''status''] == 4 )
                                        { echo "W"; }
                                    elseif ($userDates[$dates][''status''] == 5 )
                                        { echo "SH"; }
                                        }
                                    else {
                                            echo "<td width=''26'' height=''20px'' align=''center'' valign=''middle'' >".$i."</td>";
                                            }

                }
}
?>
</tr>
</tabl


e>



e>


推荐答案

row = mysql_fetch_array(
row = mysql_fetch_array(


rest,MYSQL_NUM)){
rest, MYSQL_NUM)) {


request_id =
request_id =


这篇关于需要循环帮助(我应该使用哪个循环来比较日期)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆