I think BC2COCyclist has it, it sounds like you bonked - which means your body ran out of fuel. At least it sounds like what happens to me when I bonk

There are some good threads here about what happens when we bonk and different ways to deal with it. Here is a link to a search of the nutrition forum on bonking though there is certainly other threads on other TE forums. Check them out and feel free to ask as many questions here that you need to, learning how to fuel properly for the bike can be challenging.