FROM
nuke_users
INNER JOIN useract ON (nuke_users.user_code = useract.user_code)
INNER JOIN record_doc ON (useract.record_code = record_doc.record_code)
Where useract.record_code='$record_code' and useract.useract_pri='$last_useract_pri' and pn_user_aim='$divQmr' and (record_doc.pem101!='' or record_doc.pem102!='' or record_doc.pem103!='' or record_doc.pem104!='' or
record_doc.pem105!='' or record_doc.pmw101!='' or record_doc.pmw102!='' or record_doc.pmw103!='' or record_doc.p200!='' or record_doc.p300!='' or record_doc.p402!='' or record_doc.p500!='' or record_doc.p600!='' or
record_doc.p701!='' or record_doc.p702!='' or record_doc.p800!='' or record_doc.p900!='' or record_doc.ci101!='' or record_doc.coo!='' or record_doc.cao!='' or record_doc.pmwxo!='' or record_doc.cixo!='' or record_doc.ptd!='' ) ";
}
$apDocSr = mysql_query($apDocSql) or die("ไม่สามารถ query ข้อมูลได้");
"<br> gg =".$countAp=mysql_num_rows($apDocSr);
$i=1;
while ($apData2= mysql_fetch_array($apDocSr)){