how I can loop through images files from web server?
Often, when you make an HTTP request to your server, your server will go get data from the database and return it as JSON to the client. This is how you access your data. In your example, you will likely be returning an array or a data object with an array of images in it.
Should I do this on client side or server side?
What you are essentially asking is whether to use my server and database just for data persistence or also to contain business logic as well. A simple Google Search of something along the lines of, "Business logic on client or server" will get you pointed in the right direction. You'll see there are many considerations to this, and often one way versus the other is developer preference.