Thank you for asking. I can understand the distress you are through. It appears to be a problem of Erectile dysfunction. There may be a difficulties with maintaining or sustaining erections. Multiple factors such as stress anxiety, masturbation habit, pornography use, lifestyle associated risk factors, etc needs to be explored in details. These have an important implications on one's sex life. A detailed information regarding these is needed. If needed suitable medication and instructions can help you overcome this problem. Loss of sex drive, low confidence, performance anxiety, depression can be secondary to it.
Next Steps
I suggest, you must consult with a sexologist. For more information regarding this problem, you can also post a direct query here on practo.
Health Tips
It is treatable problem. Don't worry.