Diarrhea is a symptom, not a disease. You must be sure to treat the underlying cause as well. Sometimes it's something simple like a change of food, other times it can be caused by an infection of the intestine. If he has loose, unformed stools for more than a day or two, especially if he appears listless or doesn't want to eat, be sure he sees a Vet quickly. It's not unusual to see a trace of bright red blood in the stool with diarrhea. If there is a lot of blood or if its dark red, or if he is vomiting or has a fever with the diarrhea, get the dog to a Vet immediately.
For non-serious cases, withhold food and water for 24 hours. Give him small amounts of ice cubes to eat if he seems thirsty. Keep Kaopectate on your medicine shelf. Use dosages appropriate for his weight as noted on the bottle. Dunk something he loves into the Kaopectate (small pieces of chicken) and feed him until he's had the entire dose. Repeat after every bowl movement until the stool is solid. His stool may change color until the medicine is out of his system. Pepto-Bismol also works for this and nausea. It turns the stool dark.
When you feed him, give him equal parts of cooked rice and chopped meat with the fat drained off, or cottage cheese and pasta, instead of his regular dog food until his stool is back to normal. Gradually mix dog food back into the meat/rice mixture until he's back on his normal feed. Prescription diets are available from your Vet. Check under his tail and keep the area scrupulously clean. Use Panalog if it's sore - as it almost certainly will be.