Diarrhea can be caused by numerous causes, most likely something that you have consumed has irritated your digestive tract. The mucus is mostly likely caused by your empty intestines.
Very simply, "garbage in equals garbage out". A bad meal will make mucousy diarrhea. However, so will Chron's disease and especially ulcerative colitis.
The most common cause of diarrhea with mucus is irritable bowel syndrome. Other reasons could be ulcers, bacterial infection, anal cracks or bowel obstruction