The question is a little old, but come on.
First, I recommend the use of bootstrap, which will already make your work much easier. After placing the files in the folder and creating their references in your file create a modal (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 html structure above, put your php content (in the $totalcerto case) inside the div tag with class = 'modal-body', use php the normal way, as you would on any html page.
To call the modal, just create inside the tag <head>
that script:
<script>
$(function(){
$('#myModal').on('shown.bs.modal', function () {
$('#myInput').focus();
})
})
</script>
Just one remark, your php code does not seem to be efficient, because
If you have about 10 questions, you would have to repeat that code 10
times so that your variable $totalcerto could add the amount of
hits
Use Bootstrap: http://getbootstrap.com/javascript/#modals
– Ivan Ferrer
You’ve already made the modal appear?
– RFL