Hi,
I am getting multiple records for only one user and I need that per row I can have only one user record and on next line is the next user.
Here is the code.
(Here is the screen short
user display)
here is the screen short form by table which i am using ....
Tables
<<pre lang="xml">table >
<?php
SELECT
hs_hr_leave.leave_date,
hs_hr_leave.leave_status,
hs_hr_leave.leave_comments,
hs_hr_leavetype.leave_color,
hs_hr_employee.emp_firstname,
hs_hr_employee.emp_lastname,
hs_hr_employee.emp_middle_name,
hs_hr_compstructtree.title
FROM
hs_hr_leave
INNER JOIN hs_hr_leavetype ON hs_hr_leave.leave_type_id = hs_hr_leavetype.leave_type_id
INNER JOIN hs_hr_employee ON hs_hr_leave.emp_depment = hs_hr_employee.work_station
INNER JOIN hs_hr_compstructtree ON hs_hr_compstructtree.dept_id = hs_hr_leave.emp_depment
WHERE
hs_hr_leave.emp_depment = $depid";
$deprest = mysql_query($depsql);
if(mysql_num_rows($deprest) == 0){
?>
<tr>
<td><b>No Records to Display !</b></td>
</tr>
</table>
<?php
}else
{
while ($row = mysql_fetch_array($deprest, MYSQL_NUM)) {
$leave_date = $row[0];
$leave_status = $row[1];
$leave_comments = $row[2];
$leave_color = $row[3];
$emp_fname = $row[4];
$emp_lname = $row[5];
$emp_mname = $row[6];
$demp_title = $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,'deptitle' => $demp_title,'emplname' => $emp_lname);
print_r($userDates[$dbuser]);
}
foreach($userDates[$dbuser] as $E) { ?>
<tr>
<td width="18%" colspan="2"><strong><?php echo $userDates[$dbuser]['emplname'] ?></strong></td>
<td width="12%" colspan="2"><strong><?php echo $userDates[$dbuser]['deptitle'] ?></strong></td>
<?php
$num = cal_days_in_month(CAL_GREGORIAN, $DMonth, $DYear); // 31
$arrydats = array_fill (1,$num,"");
$i=0;
foreach($arrydats as $d)
{
$i++;
$dates = date("Y-m-d", mktime(0, 0, 0, $DMonth,$i, $DYear));
$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>