Jump to content

waqas47

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

waqas47's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Bump ...any plz need help ...to solve ...this problem
  2. hi i have to compare dates one from database and other from the loops ..if they match background color will change ... so far i have done very thing but the problem i am getting that in while loop i am getting one date to compare with all 365 days in the year ...which are coming from the loop.. i need help to solve this... <?php if (isset($emplistshow) && ($emplistshow == 'show')) { $monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); ?> <div class="outerbox" style=" float: left;"> <table colspan="5" rowspan="4"> <tr > <td width="18%" colspan="2"><strong>Month</strong></td> <td width="12%" colspan="2"><strong>Division</strong></td> <?php for($m=1;$m <=31;$m++) { ?> <td width="26" height="20px" align="center" valign="middle" ><?php echo $m; ?></td> <?php } ?> </tr> </table> </div> <div class="outerbox" style=" float: left;"> <table > <?php //$sql ="SELECT leave_date,leave_type_id,leave_request_it, FROM `hs_hr_leave` WHERE employee_id = $emplid "; //loop to print numbers if months in a given year for($Month=1;$Month <= 12;$Month++) { ?> <tr> <td width="18%" colspan="2"><strong><?php echo $monthNames[$Month-1]; ?></strong></td> <td width="12%" colspan="2"><strong>Division</strong></td> <?php $num = cal_days_in_month(CAL_GREGORIAN, $Month, $cYear); // 31 //$dates = date("$cYear-$Month-1"); $sql ="SELECT leave_date,leave_status,leave_comments,leave_type_id,emp_depment FROM `hs_hr_leave` WHERE employee_id = $emplid "; $res = mysql_query($sql); //loop to print numbers if days in a given month for($i=1;$i<=$num;$i++) { ///$dates = date("$cYear-$Month-$i"); $dates = date("Y-m-d", mktime(0, 0, 0, $Month, $i, $cYear)); $checkdate = strtotime($dates); //loop to print dates from database while ($row = mysql_fetch_array($res, MYSQL_NUM)) { //echo $time2=date("Y-n-j",strtotime ($row[0])).'<br/>'; //here you have to seprate the year month and day coming from db and pas it to mktime function as doing above ///like $dates = date("Y-n-d", mktime(0, 0, 0, $Month, $i, $cYear)); $status = $row[1]; $comments = $row[2]; $typeid = $row[3]; $depment = $row[4]; $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 = strtotime($dbuser); //echo $dbuser.'<br/>'; //echo $dates.'<br/>'; } //echo $dbuser.'<br/>'; //echo $checkdate ."==". $userDates.'<br/>'; if($checkdate == $userDates) { //echo $typeid ; $cSql = "SELECT leave_type_name,leave_color FROM hs_hr_leavetype WHERE leave_type_id = '$typeid' "; $cRes = mysql_query($cSql); while ($color = mysql_fetch_array($cRes, MYSQL_NUM)) { //echo $color[1]; //echo $color[0]; //echo $status."<br/>"; echo "<td width='26' title='".$comments."' height='20px' bgcolor='#".$color[1]."' align='center' valign='middle' >"; if($status == -1) { echo "R"; } elseif ($status == 0 ) { echo "C"; } elseif ($status == 1 ) { echo "PA"; } elseif ($status == 2 ) { echo "A"; } elseif ($status == 3 ) { echo "T"; } elseif ($status == 4 ) { echo "W"; } elseif ($status == 5 ) { echo "SH"; } echo "</td>"; } } else { echo "<td width='26' height='20px' align='center' valign='middle' >".$i."</td>"; } } } ?> </tr> </table>
  3. hi i am am making a leave calendar ...i want to compare dates and if the matches the background will be changed . i am try to do is i got two loops first for 12 months and seconds for numbers of days in that month and i am using $num = cal_days_in_month(CAL_GREGORIAN, $Month, $cYear) this will give be numbers of days in that month... then there is a my sql query which will select that dates and other data from database .. now problem i am have is that numbers of days are not increment it show date like 2011-1-1 ,2011-1-1 and so on instead of 2011-1-1, 2011-1-2.... plz help me ..here <<pre lang="xml">table > <?php for($Month=01;$Month <= 12;) { ?> <tr> <td width="18%" colspan="2"><strong><?php echo $monthNames[$Month-1]; ?></strong></td> <td width="12%" colspan="2"><strong>Division</strong></td> <?php $num = cal_days_in_month(CAL_GREGORIAN, $Month, $cYear); // 31 //$dates = date("$cYear-$Month-1"); $sql ="SELECT leave_date,leave_status,leave_comments,leave_type_id FROM `hs_hr_leave` WHERE employee_id = $emplid "; $res = mysql_query($sql); for($i=1;$i<=$num;$i++) { $dates = date("$cYear-$Month-$i"); //echo $dates."<br/>"; while ($row = mysql_fetch_row($res, MYSQL_NUM)) { $time2=date("Y-n-j",strtotime ($row[0])).'<br/>'; echo "<td bgcolor='red'>".$dates."--".$time2."</td>"; //echo "<td>".$row[1]."</td><br/>"; //echo "<td>".$row[1]."</td><br/>"; //echo "<td>".$row[2]."</td><br/>"; } echo "<td width='26' height='20px' align='center' valign='middle' >".$i."</td>"; } //echo "<br/>"; $Month++; } ?> </tr> </tabl
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.