I give up. If all you want are *ALL* the user_ids, once each, why are you involving the programs
table, at all?
And why are you mucking with
WHERE title_id = '$trimmed' and prog_id = '$prog_id' ")
To get what you *SAY* you want, you simply need to do
SELECT DISTINCT user_id FROM title_views
But you must have *some* reason for doing what you are doing, though I don't think we can figure that out from what you have posted so far.