Bananas are one of the best for this.
But if you have diarrhoea, unpleasant as it is, it is actually better to allow it to progress - unless a doctor or nurse tells you it's ok to take something to stop it. I say that because diarrhoea is one of the body's ways of getting rid of something that it regards as harmful. To stop this process could result in keeping harmful bacteria etc within the gut. If you are having frequent bouts of diarrhoea it's always best to get a second opinion from your health care practitioner.