Mag sein das es andere Wege gibt aber hole Dir die Inhalte deiner Schleife doch via ajax:
in der html jquery einbinden.
js
Code
function lehrerAuswahlFeld(){
var anfrage = 'lehrerAuswahlFeld';
$.ajax(
{
method: "POST",url: "http://"+window.location.hostname+"/pfad zu deiner php/filename.php",
data: {
action: anfrage
}})
.done(function(antwort){
// gibt die Antwort welche dein php via "echo" schmeist zurück;
$('#meineId').append('<form method="POST" action="" submit="">'+antwort+'</form>');
});
};
Alles anzeigen
php