hi all…
while running this code these warning msgs are shown to me…plz guide me how to solve it…acording to me there is a prob. in my select statemnt…
if i use die statement then parse error comes on line no. 21…
Warning: Supplied argument is not a valid MySQL result resource in c:\apache\htdocs
ewhr\attendance.php on line 20
Warning: Supplied argument is not a valid MySQL result resource in c:\apache\htdocs
ewhr\attendance.php on line 20
Warning: Supplied argument is not a valid MySQL result resource in c:\apache\htdocs
ewhr\attendance.php on line 20
<?php
mysql_connect("localhost","root","root");
mysql_select_db("master");
$dates = array();
$employee = array();
$attendance_record = array();
$getdates = "select * from mar10 order by Date";
$dates_resultset = mysql_query($getdates);
while ($dates_data = mysql_fetch_assoc($dates_resultset))
{
$dates[] = $dates_data['Date'];
}
$get_employee = "select * from emp_company";
$employee_resultset = mysql_query($get_employee);
while ($employee_data = mysql_fetch_assoc($employee_resultset))
{
$get_attendance = "select * from at0310 where ecode=".$employee_data['ecode']." and atdate in (".implode(",",$dates).") order by atdate" or die(mysql_error());
$employee[$employee_data['ecode']] = $employee_data['ename'];
$attendance_resultset = mysql_query($get_attendance);
while ($attendance_data = mysql_fetch_assoc($attendance_resultset))
{
$attendance_record[$employee_data['ecode']][$attendance_data['atdate']]['attendance'] = "P";
}
}
$tabledata = "";
$tabledata .= "Empcode Name \ ";
foreach ($dates as $key => $value) {
$tabledata .= $value." \ ";
}
$tabledata .= "\\r\
";
foreach ( $employee as $emp_key => $emp_value )
{
$tabledata .= $emp_key."/".$emp_value;
foreach ( $dates as $dates_key => $dates_value )
{
$tabledata .= "\ ";
if ( isset($attendance_record[$emp_key][$dates_value]['attendance']) ) {
$tabledata .= $attendance_record[$emp_key][$dates_value]['attendance'];
}
else
{
$tabledata .= "A";
}
}
$tabledata .= "\\r\
";
}
$file_resource = fopen("att.txt","w+");
fwrite($file_resource,$tabledata);
mysql_close();
?>