You have few issues with your code:
- You haven't added php start code syntax properly at few places ( i.e. you should write
<?php
instead of<?
). - You've to end endif loop with a Semicolon (;).
- You have to remove ```````` appearing at the end of the code.
By implementing these two fixes, your existing errors will be fixed hopefully.