I am trying to fetch all rows with the Id that is taken from getting the cat_id:
<?php require_once '../db_con.php'; 
if(!empty($_GET['cat_id'])){
    $doc = intval($_GET['cat_id']);
try{
    $results = $dbh->prepare('SELECT * FROM cat_list WHERE cat_id = ?');
    $results->bindParam(1, $doc);
    $results->execute();
    } catch(Exception $e) {
    echo $e->getMessage();
    die();
    }
    $doc = $results->fetch(PDO::FETCH_ASSOC);    
    if($doc == FALSE){
        echo '<div class="container">';
        echo "<img src='../img/404.jpg' style='margin: 40px auto; display: block;' />";
        echo "<h1 style='margin: 40px auto; display: block; text-align: center;' />Oh Crumbs! You upset the bubba!</h1>";
        echo '<a href="userList.php"  style="margin: 40px auto; display: block; text-align: center;">Get me outta here!</a>';
        echo'</div>';
        die();
    }
}
?>
If I just use:
$doc = $results->fetch(PDO::FETCH_ASSOC);  
It fetches a single row as expcted
However if I use:
$doc = $results->fetchAll(PDO::FETCH_ASSOC);  
I get the following error?
Notice: Undefined index: doc_id in /Applications/MAMP/htdocs/dashboardr v3.1.7/catView.php on line 126
Notice: Undefined index: doc_title in /Applications/MAMP/htdocs/dashboardr v3.1.7/catView.php on line 126
But if I var_dump($doc);
It does return the values:
array(2) { [0]=> array(3) { ["doc_title"]=> string(5) "dsfsd" ["cat_no"]=> string(1) "4" ["doc_id"]=> string(2) "72" } [1]=> array(3) { ["doc_title"]=> string(14) "Adams Test Doc" ["cat_no"]=> string(1) "4" ["doc_id"]=> string(3) "120" } } 
I am really confused?
UPDATE
<?php include 'header.php'; ?>
<?php require_once '../db_con.php'; 
if(!empty($_GET['cat_id'])){
    $cat = intval($_GET['cat_id']);
try{
    $results = $dbh->prepare("SELECT doc_list.doc_title, doc_list.cat_no, doc_id FROM doc_list WHERE cat_no = ?");
    $results->bindParam(1, $cat);
    $results->execute();
    } catch(Exception $e) {
    echo $e->getMessage();
    die();
    }
    $doc = $results->fetch(PDO::FETCH_ASSOC);    
    if($doc == FALSE){
        echo '<div class="container">';
        echo "<img src='../img/404.jpg' style='margin: 40px auto; display: block;' />";
        echo "<h1 style='margin: 40px auto; display: block; text-align: center;' />Oh Crumbs! You upset the bubba!</h1>";
        echo '<a href="userList.php"  style="margin: 40px auto; display: block; text-align: center;">Get me outta here!</a>';
        echo'</div>';
        die();
    }
}
?>
<h3 class="subTitle"><i class="fa fa-file-text"></i> </span>Document List</h3>  
   <p><?php 
   var_dump($doc);
   echo '<a href="docView.php?doc_id='.$doc["doc_id"].'">'.$doc['doc_title'].'</a>' ?></p>
   I WANT ALL MY RESULTS LISTED HERE
</div>
</div>
 
    