Stomach pain is caused due to two main reasons on the account of loose motion:
The high contraction of abdominal muscles that constantly pass out feces
The presence of gas in the stomach, caused due to retention of undigested foods.
In order to treat this, you can follow the given steps:
Stay away from any spicy or oily foods
Try to incorporate as much whole foods as possible in your diet. This can also come in the form of health drinks.
Stay hydrated all the time.
Avoid caffeine and alcohol
BRAT diet
Eat cooling spices such as mint and ginger to relax the abdominal muscles.