The fuel level sensor in the tank is bad.The contacts are made of silver and the epa made the gas companies remove more sulpher from gasoline and it caused a substance called sulpher oxides.That eats away at the sensor contacts and causes the condition you describe.The gas tank will need lowered or the bed removed to replace the sensor but it will solve your problem.
Master ASE Certified.L1 Advanced Engine Performance Certified.Pa Emission Repair Technician.Just Answer Car Category Mentor.