Praise be to Allah.
Allah, may He be exalted, has granted a concession allowing the sick person for whom it is difficult to fast to break his fast and make up the days when he did not fast. Allah, may He be exalted, says (interpretation of the meaning):
“and whoever is ill or on a journey, the same number (of days which one did not observe Saum (fasts) must be made up) from other days. Allah intends for you ease, and He does not want to make things difficult for you”
The kind of sickness that makes it permissible for the fasting person to break his fast is the kind of sickness that makes it difficult to fast, or that makes the sickness worse, or will delay recovery as a result of fasting. For more information, please see fatwa no. 12488
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said:
The situation of the one who is sick may be of different types:
1. Cases that are not affected by fasting, such as a slight cold, a mild headache, toothache, and the like. In such cases it is not permissible for him to break the fast.
2. Cases where it is difficult for him to fast, but it will not harm him. In this case it is makrooh for him to fast and it is Sunnah for him to break the fast.
3. Cases in which it is difficult for him to fast and he will be harmed by that, as in the case of a man who has kidney disease, diabetes and the like. In such cases, it is haraam for him to fast.
End quote from ash-Sharh al-Mumti‘ (6/341).
Based on that, if the diarrhoea is mild, and will not affect the fast or cause exhaustion or undue hardship, then it is not permissible for the fasting person to break his fast, and he must complete his fast.
But if the diarrhoea is severe, to the extent that the fasting person feels tired and exhausted, then he has to break his fast. The person who suffers diarrhoea needs to make up what his body has lost of fluids and salts, and if he does not do that, then he is exposing himself to the risk of severe exhaustion.
If the diarrhoea is even worse than that, in the sense that if he does not take medicine to stop this diarrhoea and replenish the fluids and salts that his body has lost, there is the fear that he will suffer harm, then in this case he must break his fast and it is haraam for him to carry on fasting.
But then he has to fast a day to make up for this day, after Ramadan ends.
To sum up: so long as the diarrhoea has reached the stage of causing tiredness and exhaustion, it is mustahabb for you to break the fast and it is makrooh for you to carry on fasting in the face of this hardship, and you should make up that day later on.
We ask Allah, may He be exalted, to heal you.
And Allah knows best.