Get product by ItemName rather than ItemID on detail page
I'm trying to pass product info by name rather than item id for seo purposes. I've got a site where I've done this and it works fine so the detail url will be:
detail.php?ItemName=Roses which I can rewrite with my .htaccess file. However, I need also to pass the ItemID as the variants recordset does not contain the item name, so previously when I was passing the item by ID the SELECT statement was:
SELECT *
FROM itemvariants
WHERE VarItemID=colname (colname contains the $_GET['ItemID'] command).
If I pass the item by name I can't GET the ItemID, what would be the best way of passing this to the detail page?