Not sure if these will be a complete solution, but here are a few things I noticed:
1. Try adding white space after your opening php tags:
<?php} else {?> // Incorrect
<?php } else { ?> // Correct
<?php}?> // Incorrect
<?php } ?> // Correct
2. Looks like you are missing a closing div for .img-container.
3. Does your code include an endwhile?