Using _GET method on URL that has been changed by .htaccess file

  .htaccess, get, mysql, mysqli, php

I changed my url using the .htaccess file to change my url from /forum.php?cat=AutoCat to /forum/AutoCat

.htaccess file

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ $1.php
    RewriteBase /                       
    RewriteRule ^forum/(.*)$ forum.php?cat=$1&%{QUERY_STRING} [QSA,L]

Using the _GET I want to get the name of the category that has been searched to to use it in this php function and be able to echo data that is in the same row.

        $id = $_GET['cat'];
        $sql = "SELECT * FROM `categories` WHERE category_name=$id";
            $result = mysqli_query($conn, $sql);
            while($row = mysqli_fetch_assoc($result)){
                $catname = row['category_name'];

Source: Ask PHP