A bit of a crap subject this - sorry - but I had a bout of diarrhoea yesterday

that was awful because the last time I had it was about 20 years ago.
It all started around 3am. I was in bed, sleeping (of course) and I suddenly woke with a nasty pain in my stomach. Within minutes I was rushing to the lav and was doing so every 10 minutes after that for the next eight hours.
I was told it's a condition that could last up to four days.
So I asked a friend about it. He'd had it and he had found a 'cure'.
I told him it was probably an egg and mayonnaise sandwich that caused it.
But he gave me a list of things to eat and guess what it soon went away.
So I ate:
1) Four cheese pasties.
2) One big bar of chocolate.
3) Drank two pints of whole milk.
So, what happened and why did it work? Thanks.