The saying was to remind people to watch which way you write it. In other words, pay attention to what you're doing. It is currently synonymous with "Be polite and mind what you say."
It comes from 19th-century school-teachers reminding children who are learning cursive not to mix up which way the loops on lower-case p and q are facing, and later was used to mean be mindful of all things. There is a long-running joke that it meant "mind you pints and quarts" in 17th-century English pubs. This story has no historical basis and seems to have been concocted in the last couple of decades as a joke that (due to a widely circulating chain e-mail) has begun to be accepted as true.