Rettelse af foreach-løkken ??
Hejsa !Jeg har denne kode:
<tr><td>
<?php foreach ($searchResults as $subject => $courses) { ?>
<table align="left" class="academylisting">
<tr><td bgcolor="#ffffff"></td></tr>
<tr>
<td style="background-color: white">
</td>
<td style="background-color: white;" colspan="12">
<h2 style="text-align: left"><?= $subject ?></h2>
</td>
</tr>
<tr>
<th style="background-color: white">
</th>
<th>
Nr
</th>
<th>
Navn
</th>
<th>
Dg.
</th>
<th>
Pris
</th>
<th>
Sted
</th>
<?php foreach ($selmonths as $month) { ?>
<th>
<?= $site->cutString($monthnames[$month], 3, false) ?>
</th>
<?php } ?>
</tr>
// Denne løkke skal kun køre en gang
<?foreach ($courses as $number => $course) { ?>
<tr>
<td rowspan="<?= count($course['locations']) ?>" style="background-color: white">
<a href="?page=a_beskrivelser&course=<?= $number ?>"><img src="info.gif" alt="Se information om dette kursus" border="0"></a>
</td>
<td rowspan="<?= count($course['locations']) ?>">
<?= $course['number'] ?>
</td>
<td rowspan="<?= count($course['locations']) ?>">
<?= $course['caption'] ?>
</td>
<td rowspan="<?= count($course['locations']) ?>" align="center">
<?= $course['duration'] ?>
</td>
<td rowspan="<?= count($course['locations']) ?>" style="padding-right:4px" align="right">
<?= $course['price'] ?>
</td>
<?php if (count($course['locations']) == 1 && isset($course['locations']['none'])) { ?>
<td colspan="<?= count($selmonths) + 1 ?>">
<a href="?page=interesselis">Ring og hør!</a>
</td>
</tr>
<?php } else { ?>
<?php foreach ($course['locations'] as $location => $months) { ?>
<td>
<?= $location ?>
</td>
<?php foreach ($months as $month => $dates) { ?>
<td align="right" width="60">
<?php foreach ($dates as $calenderId => $dateInterval) { ?>
<?= $dateInterval ?> <input class="academylisting" style="border: none; background-color: #FAEFDD" TYPE="checkbox" name="courses[<?= $calenderId ?>]" value="<?= $dateInterval ?>"><br>
<?php } ?>
</td>
<?php } ?>
</tr>
<?php } ?>
<?php } ?>
<?php } ?>
</table></td></tr>
<!-- start new row -->
<tr><td>
<?php } ?>
</td>
</tr>
<tr>
<td style="padding-right:5px">
<div align="right">
<input type="button" onClick="window.location = '?page=a_kalender'" value="Retur">
<?= $courseSelectForm->elements['select']->toHtml() ?>
</div>
</td>
</tr>
</table>
</div>
<?= $courseSelectForm->formEndToHtml() ?>
og vil gerne have at den markerede løkke (// Denne løkke...) KUN kører en gang.
Hvordan retter jeg den foreach så jeg opnår det ?
