<?php 
    $i=0;
    $select = $db->prepare("SELECT * FROM `tbl_docs` WHERE registID = '".$regid."' AND attach_type=1 ORDER BY doc_id DESC");
    $select->execute(); 
    while($row = $select->fetch()){
        $doc_id = $row['doc_id'];
        $uploaded_on = $row['uploaded_on'];
        $docName = $row['docName'];
        $rec_dpt = $row['rec_dpt'];
        $usID = $row['usID'];
        $stts_doc = $row['stts_doc'];
        $i++;
        
        //Hide Extension
        $file = new SplFileInfo($docName);
        $ext  = $file->getExtension();
        //Get File Name
        $fileName = basename($docName);
        $fileNameNoExtension = preg_replace("/\.[^.]+$/", "", $fileName);

        //DOC ICON
        if($ext == "pdf"){
        $imgIcon = "pdf.png";
        }if($ext == 'xls' || $ext == 'xlsx'){
        $imgIcon = "excel.png";  
        }if($ext == 'doc' || $ext == 'docx'){
            $imgIcon = "docx.png";
        }if($ext == 'ppt' || $ext == 'pptx'){
            $imgIcon = "pptx.png";
        }if($ext == 'zip' || $ext == 'rar' || $ext == 'tar'){
        $imgIcon = "zip.png";
    }
    ?>                    
    <a href="../docs/<?php echo $docName;?>">
        <img src="../img/icon/<?php echo $imgIcon;?>" width="30" title="<?php echo $docName;?>">
    </a> 
    <?php 
    }
?>