PHP using $_GET['id'] to display database information : <p>I'm trying to build a forum with PHP and PDO at the moment and I have a link which takes you to the page for a category with the categories ID in the URL (eg. WEBSITE/category.php?id=1). When I get there, I want to display the name of the category you are looking at using this $_GET information, but it won't seem to do it for me. 
Here is what I've got:</p>

<pre><code>&lt;?php

include 'dbconfig.php';
include 'header.php';
$sql = "SELECT cat_id, cat_name, cat_description FROM categories WHERE cat_id = " . $_GET['id'];
$query = $DB_con-&gt;prepare($sql);

$query-&gt;execute();

$numRows = $query-&gt;fetchColumn();

if (!$query) {
    echo 'Something went wrong whilst getting the category from the database.';
} else {
    if ($numRows == 0) {
        echo 'Sorry, this category does not exist';
    } else {
        while($catRow = $query-&gt;fetch(PDO::FETCH_ASSOC)){
            echo $catRow['cat_name'];
        }
    }
}

include 'footer.php';
?&gt;
</code></pre>

<p>So as you can see, I have tried to make a while loop that creates an array using PDO::FETCH_ASSOC allowing me to print category details, but when I go to the page nothing shows up except the header.php and the footer.php. There also aren't any errors that come up. Can anybody see what I'm doing wrong? Or let me know if there's information that I have left out. Thanks.</p>
