<tr> <th>Sanitäter</th> <th>Handy</th> <th></th> </tr> </thead> <tbody> <?php $db = new Database(); $con = $db->connectUser(); $anwesend_result = $db->select_anwesend($con, $akw, 's.sanitaeterid'); while ($anwesend = $anwesend_result->fetch_assoc()) { $dienst_result = $db->select_dienst_by_id($con, $akw, $anwesend['sid']); $dienst = $dienst_result->fetch_assoc(); $handy_result = $db->select_handy($con); echo '<form action="handy.php?PHPSESSID=' . $_GET['PHPSESSID'] . '" method="post">'; echo '<input type="hidden" name="sid" value=' . $anwesend['sid'] . '>'; echo '<tr>'; echo "<td>" . $anwesend['vorname'] . " " . $anwesend['name'] . "</td>"; echo '<td>'; echo '<select class="form-control" name="handy">'; echo '<option value=" 0 "> Kein Handy </option>'; while ($handy = $handy_result->fetch_assoc()) { if ($anwesend['sid'] == $handy['SanitaeterID']) { echo '<option selected="selected" value="' . $handy['HandyID'] . '">Handy ' . $handy['HandyID'] . ': ' . $handy['Handynummer'] . '</option>'; } else { echo '<option value="' . $handy['HandyID'] . '">Handy ' . $handy['HandyID'] . ': ' . $handy['Handynummer'] . '</option>'; } } echo '</select>';