This is related to the knapsack and bin-packing problems, which in general are NP-hard...; if you want the playlist to be exactly 3600 seconds long, then it's an instance of the subset-sum problem, which is NP-complete (although faster algorithms exist for approximate solutions where you're allowed to have a wee gap at the end).
I don't see a straightforward way of doing it in the database without a stored procedure to implement something that might as well be implemented in PHP.
So, I'd read in all of pairs of songID/duration in the table into an array in PHP to serve as the songlist, and do the work there. Shuffle that songlist array.
Start with a total duration of 0 seconds, and an empty array for the playlist.
While the total duration is less than 3600 seconds, pop a song off the songlist.
If the duration of the song is less than 3600 - total duration, put the songID in the playlist, add its duration to the total duration.
Continue through the loop until you run out of songs in the songlist.
One thing you might do to speed the loop up a bit is to see what the shortest song in the songlist is; you can stop looking as soon as the gap in your one-hour playlist is smaller than that duration.