// end while for topics
        } else {
            F_display_db_error();
        }
    }
    // end while for module
} else {
    F_display_db_error();
}
$pdf->lastpage(true);
$pdf->SetAutoPageBreak(false);
$pdf->SetFont('helvetica', '', 5);
$pdf->SetTextColor(0, 127, 255);
$msg = "Powered by TCExam (www.tcexam.org)";
$lnk = "http://www.tcexam.org";
$pdf->SetXY(15, $pdf->getPageHeight(), true);
$pdf->Cell(0, 0, $msg, 0, 0, 'R', 0, $lnk, 0, false, 'B', 'B');
// set PDF file name
switch ($expmode) {
    case 1:
        $pdf_filename = 'tcexam_subject_' . $subject_id . '_' . date('YmdHi') . '.pdf';
        break;
    case 2:
        $pdf_filename = 'tcexam_module_' . $module_id . '_' . date('YmdHi') . '.pdf';
        break;
    case 3:
        $pdf_filename = 'tcexam_all_modules_' . date('YmdHi') . '.pdf';
        break;
    default:
        $pdf_filename = 'tcexam_export_' . date('YmdHi') . '.pdf';
        break;