I think you can change the INNER JOIN to a LEFT OUTER JOIN in your recordset. Then update the IF statement on line 50 from:
if ($Categories->TotalRows > 0)
to:
if ($Categories->getColumnVal("ProductCategoryID"))
If that causes other issues, then the alternative solution is to use two recordsets.