Hadroproduction and Photoproduction of c and b Hadrons