How do I know if my son has an attachment problem if he cries when he goes to school?

Very unlikely. Younger children who refuse to attend school are more likely to have separation anxiety (disorder) rather than attachment disorder. Older anxious children usually do so because of social phobia.
Separation Anxiety. Kids will often have normal separation anxiety as they start school, especially for the first time. Most kids will quickly adapt but will need teacher and parental support. If the child seems to have excessive problems with the separation, or it continues longer than a couple of weeks, then address the issue with your pediatrician.