so the URL is passing the category name:
/categories/category-name
but in the recordset you are trying to use the Category ID:
WHERE ProductCategoryID = colnamez
and then you say:
& colnamez as : $row_categories['CategoryID']
meaning you are using the category ID returned by the recordset.
This is circular logic.
first off, what is the name of the URL variable that is created by your mid rewrite link. in other words, what is mod rewrite converting the URL to:
/categories/category-name
category-name should get converted to a URL variable, something like:
?CategoryName=<Name of category>
in your recordset, you would need to set the WHERE clause to filter the category name column on the URL variable.