Fuel gauge only working sometimes

You need to try and catch this when it's not working, and don't move the car. Access the sending unit (easiest) by removing the left kick panel and separating the connector. Check the ohms reading from the sender wire to ground. A high or open reading means

Either a problem in the sender wire (end connector probably)

An ungrounded sender

Or a bad sender.

If you are getting a reading "somewhere in the range" the gauge would "like to see" then the trouble is up towards the gauge. (10 or so to 73 or so ohms) Don't discount "simple crap." On mine the fake nuts on the gauges were not making contact on the gauge studs