Since it was not mentioned in the problem, we can safely assume that the costs of tickets for students and teachers are just equal. Let's denote this total cost as variable x. The equation for the total cost would be:
x = 39(2) + 39(23)
x = 78 + 897
x = $975
So, the total cost of tickets for all is $975.