<?php
$mysql_dept ="select dept_code,dept_name,re_person,c_person from tbla_dept ";
$recset_dept = $conn->execute( $mysql_dept );
while (!$recset_dept->EOF )
{
$lv_deptcode=$recset_dept->fields[ 0 ];
$lv_deptname = $recset_dept->fields[ 1 ];
$lv_resp = $recset_dept->fields[ 2 ];
$lv_copyper = $recset_dept->fields[ 3 ];
$mysql_dept1="Select i_no,mg.dept_code,dept_name,s_no,i_code_no,
to_char(first_cali,'dd-Mon-yyyy'),
sch_frequency,re_person,c_person from tbla_i_list mg,tbla_dept d
where to_char(first_cali,'MM-YYYY')='$lv_curr_month' and mg.DEPT_CODE=d.DEPT_CODE
and d.DEPT_CODE='$lv_deptcode'
union
select g_id,mh.dept_code,dept_name,s_no,g_code_no,to_char(first_cali,'dd-Mon-yyyy'),
sch_frequency,re_person,c_person from tbla_g_list mh,tbla_dept d where
to_char(first_cali,'MM-YYYY')='$lv_curr_month'
and mh.DEPT_CODE=d.DEPT_CODE and d.DEPT_CODE='$lv_deptcode' order by s_no";
$recset_dept1 = $conn->execute( $mysql_dept1 );
:):)
/*using this above query
i get following output
dept1 = 29 rows
dept2 = 3 rows
dept3 = 5 rows
dept4 = 1 row
dept5 = 1 row
dept6 = 2 rows
dept7 = 1 row
dept8 = 1 row
*/
$desc = " <table width='100%' border='0' cellpadding='0' cellspacing='0' >
<tr bgcolor='#B0DFFF'>
<td align='center'>G Code</td>
<td width='8%' align='center'>Last Cal</td>
<td width='8%' align='center'>Due</td>
</tr>";
while (!$recset_dept1->EOF )
{
$lv_dept_name=$recset_dept1->fields[2];
$lv_g_code=$recset_dept1->fields[4];
$lv_last_cal=$recset_dept1->fields[5];
$lv_fre =$recset->fields[6];
if($lv_fre == "Daily" )
{
$date=func_addday($lv_last_cal);
}
else if($lv_fre == "Weekly" )
{
$date=func_addweek($lv_last_cal);
}
else if($lv_fre == "Fortnight" )
{
$date=func_addfortnight($lv_last_cal);
}
else if($lv_fre == "Monthly")
{
$date=func_addonemonth($lv_last_cal);
}
else if($lv_fre == "Quarterly" )
{
$date=func_addthreemonths($lv_last_cal);
}
else if($lv_fre == "h-y" )
{
$date=func_addsixmonths($lv_last_cal);
}
else if($lv_fre == "Yearly" )
{
$date=func_addyearly($lv_last_cal);
}
$col = "green";
$message = " Report ";
$to="test@email.com";
$mail_to="";
$desc.="<tr bgcolor=$lv_row_col2>
<td nowrap class='runningleft1'>$lv_g_code</td>
<td nowrap class='runningleft1'>".func_formatdate($lv_last_cal)."</td>
<td nowrap class='runningleft1'>".func_formatdate($date)."</td></tr>";
//sendemail('',"$value ($message)",$desc,$mail_to,$to,'');
$recset_dept1->MoveNext();
}
:):):)
$recset_dept->MoveNext();
}
echo " </table></td></tr></table></td></tr>";
?>
at the below kind of marked location in the above code
🙂🙂
I have added following line
$rec_Count=$recset_dept1->RecordCount();
And like i marked below i have added following code and its working fine
🙂🙂🙂
if($rec_Count !=0)
{
sendemail('',"$value ($message)",$desc,$mail_to,$to,'');
}