Looking at the rewritten code, I am wondering if you are running into a problem fetching data from the same results set twice in a row. I've tried doing that and found that the results set gets exhausted (emptied) from the fetch.
Making a copy of the results set ($results2 = $results) doesn't fix the problem, as the copy is only a symbolic link to the original, not a real copy. So when you exhaust one, you exhaust the other.
I cannot say this for sure, as you are doing a mysql_fetch_object, followed by mysql_fetch_array and I'm not sure how the two interact with each other. It is possible that when running the mysql_fetch_object, you exhaust the results set. Then when you run mysql_fetch_array against the same results set, there's nothing to fetch against.
Something for you to explore...