As you were not having an anxiety attack, and just collapsed, I would suggest you see your doctor to make sure there is no underlying problem with your legs and spine or any neurological disorder.
Best wishes.
My brother used to do that as well but he was having panic attacks from social anxiety disorder.
That is alarming. You should see a doctor about this as soon as you can, as it is possible that this is some sort of seizure. Blessings - Blu
do u think maybe ur dehydrated? are u taking any kind of meds? do u usually have back pain?