RewriteRule ^categories/(.*)$ category-details.php?catlink=$1 [NC,L,QSA,T=application/x-httpd-php]
use the UIRL variable in your recordset:
$_GET['catlink']
also, it would seam to me that the link passed the catlike column from your table right? so you should be using the catlink column in the recordset.
suppose if i m at category page called: xyz
link would be .../categories/x-y-z ('x-y-z' is Categorylink)
now if i use, $_GET['Categorylink'] then its going to use x-y-z as CategoryID.
I want x-y-z's CategoryID to be used to match with product.ProductCategoryID