Get Montezuma before he gets you. Don't eat anything with olestra in it. This applies in your country, too.

What causes traveler's diarrhea?

Viruses, bacteria, and parasites. Diarrhea will be the least of your worries if you run across E. coli, hepatitis, typhoid fever, or cholera.

Well, that's helpful -- so, how do I avoid the shits?

Don't drink the water. The water in Mexico is notorious: everyone knows this can make you violently ill. Don't have drinks with ice, or any beverage from a soda fountain. If possible, brush your teeth with bottled water. If you're feeling really paranoid, wipe the top of your soda bottle or can dry before taking a swig.

The easiest way to treat the nasty-ass water is to boil it. Go on, crank the heat all the way up, and let half of it evaporate. Kill everything. Vendetta upon the microbes. Genocide is your new past-time.

You can also disinfect the water chemically, with either iodine or chlorine. Iodine is preferrable. Don't just buy iodine from the store: use tincture of iodine, or a commercially available product designed specifically for this task. You can buy the stuff at most pharmacies, or at a local sporting goods store. If the water is cloudy, there's probably more feces in it than usual (this is often what causes infection -- you're drinking someone else's shit, and thus get the shits), and you should strain it through a piece of clean cloth and use twice as many disinfectants. Then boil it thirty or forty times.

Pray.

Food is equally dangerous. Pretty much anything that hasn't been scorched with holy fire is suspect, and may kill you, or eat you first. Vegans are in trouble: salads, uncooked fruits, and vegetables are all suspect, as are unpasteurized milk and cheese, raw meat (why are you eating raw meat in mexico, again?) and shellfish. We've been over this one before. The water's nasty. Anything that lives in the water is nastier.

What's safe?

Alcohol. Mexican beer may taste like piss, but it's only piss occasionally. Anything prepackaged or scorched to hell.

Symptoms and Treatment

The Center for Disease Control says:

The typical symptoms of travelers’ diarrhea (TD) are diarrhea, nausea, bloating, urgency, and malaise. TD usually lasts from 3 to 7 days. It is rarely life threatening.

...I can't imagine why the last two symptoms might come up. I don't know about you, but if I feel like shit, have a distended abdomen, and I'm shitting my pants every five minutes, I'd be a little upset and panicked too.

Antimicrobal drugs like doxycycline, trimethoprim/sulfamethoxazole, and flouroquinolones may shorten the amount of time you remain ill. If you're shitting blood, have a fever, or suffer from severe abdominal cramps, these are recommended.

See a goddamn doctor if the illness is bad. If you can, that is. When you feel like you're going to die, just sometimes you are going to die. And you wouldn't want to die without advance warning, now would you?

Oh, and: don't drink the water.