Philipp
Neuling
- 24.07.10 13:28 Uhr
Guten Tag,

ich habe das Forum nun angepasst und würde gerne die Themenübersicht in 2 Farben gestalten. Zurzeit sieht der Code ja so aus:

Code:
<?php foreach ($forum as $row2): ?>

<tr>
<td class="inhalt center" width="46"><img src="themes/itschi/images/<?php echo $row2['icon']; ?>topic.gif" border="0" /></td>
<td class="inhalt"><div><?php if ($row2['new']): ?><a href="viewtopic.php?id=<?php echo $row2['topic_id']; ?>&view=track#post"><img alt="Neuster ungelesener Beitrag" src="themes/itschi/images/neubeitrag.gif" border="0" /></a> <?php endif; ?><a class="forum" href="viewtopic.php?id=<?php echo $row2['topic_id']; ?>"><?php echo $row2['topic_title']; ?></a><?php echo $row2['pages']; ?></div>von <a class="<?php echo $row2['user_legend']; ?>" href="user.php?id=<?php echo $row2['user_id']; ?>"><?php echo $row2['username']; ?></a> - <span><small><?php echo $row2['topic_time']; ?> Uhr</small></span></td>
<td class="inhalt center" width="10%"><?php echo $row2['topic_posts']; ?></td>
<td class="inhalt center" width="10%"><?php echo $row2['topic_views']; ?></td>
<td class="inhalt" width="22%" style="padding-left:10px">von <a class="<?php echo $row2['topic_last_post_user_legend']; ?>" href="user.php?id=<?php echo $row2['topic_last_post_user_id']; ?>"><?php echo $row2['topic_last_post_username']; ?></a>&nbsp;<a href="viewtopic.php?id=<?php echo $row2['topic_id']; ?>&p=<?php echo $row2['topic_last_post_id']; ?>#<?php echo $row2['topic_last_post_id']; ?>"><img src="themes/itschi/images/neubeitrag.gif" border="0" title="Letzter Beitrag" /></a><br /><span><small><?php echo $row2['topic_last_post_time']; ?> Uhr</small></span></td>
</tr>

<?php endforeach; ?>



Hier werden alle erstellten Themen ausgegeben! (viewforum.php) Nun würde ich gerne Thema A mit einem bgcolor="#FF0000" erstellen und Thema B mit einem bgcolor="#0000FF"!

Und das sollte immer abwechselnd passieren. Thema C sollte wieder mit einem roten Background erstellt werden ...!

Ich komme einfach nicht auf die Lösung!

LG Philipp

Patrick_W
Administrator
- 24.07.10 14:06 Uhr
Code:
<?php $color = ''; foreach ($forum as $row2): ?>

<tr style="background:<?php echo $color = ($color == 'red') ? 'blue' : 'red'; ?>">
<td class="inhalt center" width="46"><img src="themes/itschi/images/<?php echo $row2['icon']; ?>topic.gif" border="0" /></td>
<td class="inhalt"><div><?php if ($row2['new']): ?><a href="viewtopic.php?id=<?php echo $row2['topic_id']; ?>&view=track#post"><img alt="Neuster ungelesener Beitrag" src="themes/itschi/images/neubeitrag.gif" border="0" /></a> <?php endif; ?><a class="forum" href="viewtopic.php?id=<?php echo $row2['topic_id']; ?>"><?php echo $row2['topic_title']; ?></a><?php echo $row2['pages']; ?></div>von <a class="<?php echo $row2['user_legend']; ?>" href="user.php?id=<?php echo $row2['user_id']; ?>"><?php echo $row2['username']; ?></a> - <span><small><?php echo $row2['topic_time']; ?> Uhr</small></span></td>
<td class="inhalt center" width="10%"><?php echo $row2['topic_posts']; ?></td>
<td class="inhalt center" width="10%"><?php echo $row2['topic_views']; ?></td>
<td class="inhalt" width="22%" style="padding-left:10px">von <a class="<?php echo $row2['topic_last_post_user_legend']; ?>" href="user.php?id=<?php echo $row2['topic_last_post_user_id']; ?>"><?php echo $row2['topic_last_post_username']; ?></a>&nbsp;<a href="viewtopic.php?id=<?php echo $row2['topic_id']; ?>&p=<?php echo $row2['topic_last_post_id']; ?>#<?php echo $row2['topic_last_post_id']; ?>"><img src="themes/itschi/images/neubeitrag.gif" border="0" title="Letzter Beitrag" /></a><br /><span><small><?php echo $row2['topic_last_post_time']; ?> Uhr</small></span></td>
</tr>

<?php endforeach; ?>



So müsste es funktionieren.
Das was ich hinzugefügt habe, ist rot markiert.

Der Eintrag wurde am 24.07.10 14:08 Uhr von Patrick_W geändert.

Philipp
Neuling
- 24.07.10 23:33 Uhr
Einsame Spitze!

Vielen Dank! Genau so hab ich mir das vorgestellt!

2 Beiträge Beitrag schreiben
©2010 Itschi.Net