模态图像不适用于所有图像

I am displaying some ads from my database through php. I want a modal image to be opened and display the full sized image when the particular image against an ad is clicked. I have used the code provide here http://www.w3schools.com/howto/howto_css_modal_images.asp

This works for the very first ad picture but not others. I am using the above code in the foreach() loop of php in order to make it work against all ad pictures.

Code for the image portion

foreach($ads as $ad){
<img id="myImg" src="'.base_url("uploads/".$b['images']).'" class="img-    responsive">
}

This displays the picture from the database, what I want is to show the enlarged picture in modal.