Thank you for your query,
Your symptoms are looking like irritable bowel syndrome
in which the stool may be hard some times and loose in some times in an alternate consistency.
But consult your Physician for your symptoms history, examine physically and to manage the problem.
Hope I have answered your query.