You may have more than one issue going on but if all problems happened at the same time then I would first suspect the master switch has failed. It will take some electrical testing to determine what is going on, you may also have a combination of wiring and window motor issues.

They didn't work at first the guy I bought the car from said the windows would need to be reprogrammed because the battery ran down or was taken out. Then they all worked together for about 20mins then the only one that works is the driver side

The problem can only be diagnosed through electrical testing unless a wiring or connection problem is seen visually. You can check switch connections and inspect the wiring in the boots between the doors and the body. Otherwise replacing the master switch would be the best thing to do if you're not able to do the testing to diagnose it.