All through the day, Jesus taught the people, and by late afternoon (Mark 6:35) they were hungry. The disciples would have ssolved the problem by sending the crowds away. Jesus would not agree to such a thing.
John's Gospel tells us (John 6:7) that it was Philip who pointed out that it would take two hundred denarii (eight months wages) to provide for such a multitude. A denarius was a day's wages for a working man. The disciples' resources, certainly, were all too meager to pay such a bill as that.
In reply to Philip, Jesus simply inquired as to how much food was available. At this, Andrew stepped forward to say that a boy in the crowd (John 6:8-9) had five barley loaves and two fishes, hardly enough to satisfy one hungry man. Mark records that Jesus, taking in his hands this scant supply of food and looking up to heaven, blessed and broke the bread until at last there was enough for everyone, with twelve baskets full of left-overs!
There has been much discussion as to the spiritual significance of Jesus's demonstration of power. It should be remembered that Jesus's central purpose in this part of his public ministry was to train the twelve. While this miracle was the natural resposne of the loving heart of Jesus to human need, it was, at the same time, an opportunity for him to demonstrate to his disciples that, of a truth, there are no limits to the power of God. Besides this, the feeding of the five thousand carried a spiritual message for all who witnessed it and for all who would later hear of it. Jesus's miracles were often parables of teaching. It was a way of saying to the people, I am the bread of life.