Update:
OK, so kann ich die Felder wieder füllen lassen
<form method="post" action="" name="cnt_form_reg" style="margin-top: 2em">
<?php
$z = 1;
if ($mg_anzahlkostenteilung != "" ) {
$i = 1;
} else {
$i = 0;
}
for ($i; $i <= $mg_anzahlkostenteilung
; $i++) {
$stmt = $mysqli->prepare("SELECT ma_id, ma_aNummer, ma_mid, ma_rechnugnsadresse, ma_midas
FROM bestellungen_rechnungsadresse
WHERE ma_aNummer=? AND ma_mid=?");
$stmt->bind_param("ss", $i, $code);
$stmt->execute();
$stmt->bind_result($ma_id, $ma_aNummer, $ma_mid, $ma_rechnugnsadresse, $ma_midas );
$stmt->fetch();
$stmt->close();
?>
<div class="textfeld abstand_2">
<label for="ma_rechnugnsadresse[<?php echo $z ?>]" style="width: 21.5%;"><?php if ($mg_anzahlkostenteilung >= "0" ) { echo $z .". " ; } ?> Rechnungsadresse*</label>
<select name="ma_rechnugnsadresse[<?php echo $z ?>]" id="ma_rechnugnsadresse[<?php echo $z ?>]" style="width: 40%;" required="">
<option value="">-- Bitte wählen --</option>
<?php
$frontend_firmen = frontend_firmen($mysqli);
foreach($frontend_firmen as $array){ ?>
<option value="<?php echo $array['f_code'];?>"<?php echo ($a_lager == $array['f_code'] ? "selected" : "");?>>
<?php echo $array['f_firma'];?>
<?php
if ($array['f_ab_an'] == 1) {
if ($array['f_abteilung'] > "") { echo " - " . $array['f_abteilung']; } }
?>
</option>
<?php } ?>
</select>
</div>
<div class="textfeld">
<label for="ma_midas[<?php echo $z ?>]" style="width: 21.5%;"><?php if ($mg_anzahlkostenteilung >= "0" ) { echo $z .". " ; } ?> MIDaS Nummer*</label>
<input type="text"
name="ma_midas[<?php echo $z ?>]"
id="ma_midas[<?php echo $z ?>]"
value="<?php echo htmlspecialchars($ma_midas) ?>"
pattern="[1-9]\d{4}|0[1-9]\d{3}|00[1-9]\d{2}|000[1-9]\d|0000[1-9]"
required="">
<div class="minlengthpwd" style="margin-left: 16.8em;">5 stellige Nummer</div>
</div>
<?php $z++; } ?>
<input type="submit" name="abschicken" value="Speichern"id="bearbeiten">
</form>