<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Time Table | WAKA CMEC</title>
</head>
<body>
<?php
    include'include/session.php';
    function clean($str) {
    	$str = @trim($str);
    	if(get_magic_quotes_gpc()) {
            $str = stripslashes($str);
    	}
    	return mysql_real_escape_string($str);
    }
        
    $id = clean($_GET['id']);
        
    $sq = "SELECT document FROM timetable WHERE time_table_id='$id'";
    $pages1 = mysql_fetch_array(mysql_query($sq));
    $document = $pages1['document'];
     
    $file = "../../uploads/time_table/".$document;
    
    
    $filename = $document; /* Note: Always use .pdf at the end. */

    header('Content-type: application/pdf');
    header('Content-Disposition: attachment; filename="' . $filename . '"');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . filesize($file));
    header('Accept-Ranges: bytes');

    readfile($file);
?>
</body>
</html>