Based on what you're describing (pain about 30 minutes after eating, followed by an urge to have a bowel movement, going on for 5 days), here are the most likely explanations, from most to least common:
1. Exaggerated gastrocolic reflex (often triggered by a recent GI infection)
Normally, eating triggers a reflex where the stomach signals the colon to contract and move things along, this is why many people feel an urge to defecate after meals. In some people, especially after a stomach bug, this reflex becomes exaggerated and produces cramping pain plus urgency every time they eat (Costanzo Physiology; Ganong's Review of Medical Physiology). This pattern commonly develops after a bout of acute gastroenteritis, even a mild one you may not have clearly noticed, and a 2024 systematic review in Gut found that a meaningful proportion of people develop IBS-like symptoms in the weeks following acute gastroenteritis (PMID: 39013599).
2. Acute gastroenteritis (viral or bacterial), possibly still resolving
Abdominal pain with diarrhea, especially if it started acutely, is most often gastroenteritis, from a virus, bacteria, or contaminated food (Tintinalli's Emergency Medicine; Bailey and Love's Short Practice of Surgery). Five days is a fairly typical duration for this to still be settling down, particularly bacterial causes.
3. Food intolerance or sensitivity
Lactose intolerance, or intolerance to fatty/spicy/high-FODMAP foods, can cause pain and loose stools within 30-90 minutes of eating. If it's specifically tied to certain foods (dairy, greasy food, etc.) rather than everything you eat, this becomes more likely.
4. Irritable bowel syndrome (IBS), diarrhea-predominant
IBS classically causes pain relieved by defecation, and about two-thirds of IBS patients report symptoms worsen after meals (Goldman-Cecil Medicine). Usually IBS is diagnosed only after symptoms persist beyond a few weeks, but a first flare can look exactly like what you're having.
When to see a doctor promptly - please seek medical attention if you have any of these, since they point to something needing more than home management:
- Blood or black/tarry stool
- Fever, chills
- Signs of dehydration (very dark urine, dizziness, dry mouth)
- Severe or worsening pain, or pain in one specific spot (e.g., right lower abdomen)
- Vomiting that prevents you from keeping fluids down
- Unintentional weight loss
What you can do now:
- Stick to bland, low-fat foods (rice, toast, bananas, boiled potatoes) for a few days
- Stay hydrated with water or oral rehydration solution
- Avoid dairy, caffeine, alcohol, spicy and fatty foods temporarily
- Note whether specific foods trigger it worse than others
- If it hasn't improved in another 2-3 days, or sooner if any red flags above appear, get evaluated. A doctor will likely want a stool test and basic exam to distinguish between infection, intolerance, and early IBS.
I can't give you a definitive diagnosis without an exam and possibly stool testing, but five days of a consistent post-meal pain-then-diarrhea pattern is worth having checked if it doesn't resolve in the next couple of days.