The question is kind of old, but come on.
First, I advise you to use the bootstrap, which will greatly facilitate your work. After putting the files in the folder and creating the references of them in your file, create a modal (it can be at the bottom of the page) with the following structure:
<div class="modal fade" tabindex="-1" role="dialog"> <!-- Esse modal já é oculto-->
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
In the above html structure, put your php content (in the case $ totalcerto) inside the div tag with class = 'modal-body', use php the normal way, as you would use on any html page.
In order to call modal, just create this script inside the <head>
tag:
<script>
$(function(){
$('#myModal').on('shown.bs.modal', function () {
$('#myInput').focus();
})
})
</script>
Just a note, your php code seems not to be efficient, because
if you have 10 questions, you would have to repeat that code 10
times so that its $ total variable could add up to the amount of
hits