That all looks right... the only thing I'd change is this line:
$OptionGroups->bindParam("i", "".(isset($_GET['OptionGroupID'])?$_GET['OptionGroupID']:"") ."", "-1");
My code checks to make sure that the option group id is passed in the url and won't error if it isn't.
What makes you think your code is wrong to begin with? Are you getting errors or is it not functioning as you would expect?