Need advice !

My boyfriend is experiencing sex issues for over a year now and we started dating half a year ago but he eventually thought I’d leave him cause of lack of sex he came up with excuses he’s tired and all that and he eventually told me his embarrassing problem I love him and have feelings for him and he does too but he was preparing himself that I’d leave but I don’t want this to end the relationship cause I feel like there’s hope to fixing the issue. Idk how to cope and help him understand it’s ok and that there’s other ways to please eachother and and help the situation and get his sex life up again I want to recommend he seeks help from a doc too but idk how to tell him. Anyone in a similar situation? I don’t want to leave him I know sex is important but I also believe that he can solve the problem if we both try and be patient. Is it stupid I’m staying cause I love him ? I want him and all that and it breaks my heart that he thought I’d leave him or he said I’d feel bad stick around and then give up! Which I’m not like that but I also wanna know there’s hope here to getting the sex on one day and that there’s a way in solving this! Comment but not rudely please! I love him and I don’t wanna leave him because he has some sexual difficulty and anxiety.