Bonjour, j'ai besoin d'une aide svp
J'utilise punbb comme forum et j'ai crée une page http://www.bladitour.fr/forum/dernier-post.php qui met les 10 derniers post du forum.
Je voudrais alterner la couleur des lignes, je trouve quelque code mais je sais pas ou les inserer.
j'ai mis cela dans mon tr mais ca donne ni erreur ni rien
<?
if (($compteur % 2) == 0)
echo "bgcolor=\"#FFFFFF\"";
else
echo "bgcolor=\"#000000\"";
?>
voila le code de ma page si ca pourrait aider
Merci
J'utilise punbb comme forum et j'ai crée une page http://www.bladitour.fr/forum/dernier-post.php qui met les 10 derniers post du forum.
Je voudrais alterner la couleur des lignes, je trouve quelque code mais je sais pas ou les inserer.
j'ai mis cela dans mon tr mais ca donne ni erreur ni rien
<?
if (($compteur % 2) == 0)
echo "bgcolor=\"#FFFFFF\"";
else
echo "bgcolor=\"#000000\"";
?>
voila le code de ma page si ca pourrait aider
Code:
<?php
//-------------------------------------------------//
//--Fonctions pour recuperer les messages recents--//
//-------------------------------------------------//
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
//requete pour récuperer le nombre de ligne
$sql = 'SELECT t.id FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL ORDER BY t.posted DESC LIMIT 0,10';
$result = $db->query($sql) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
$num_hits = $db->num_rows($result);
$search_ids = array();
while ($row = $db->fetch_row($result))
$search_ids[] = $row[0];
$db->free_result($result);
$search_results = implode(',', $search_ids);
//requete pour récuperer les derniers messages
$sql = 'SELECT t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id FROM '.$db->prefix.'topics AS t WHERE t.id IN('.$search_results.') ORDER BY t.last_post';
$result = $db->query($sql) or error('Unable to fetch search results', __FILE__, __LINE__, $db->error());
$search_set = array();
while ($row = $db->fetch_assoc($result))
$search_set[] = $row;
?>
<div id="vf" class="blocktable">
<h2><span>Discussions récents</span></h2>
<div class="box">
<div class="inbox">
<table cellspacing="0" border="1">
<thead>
<tr>
<th class="tcl" scope="col"><?php echo $lang_common['Topic']; ?></th>
<th class="tc2" scope="col"><?php echo $lang_common['Forum'] ?></th>
<th class="tc3" scope="col"><?php echo $lang_common['Replies'] ?></th>
<th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
</tr>
</thead>
<tbody>
<? // Fetch the list of forums
$result = $db->query('SELECT id, forum_name FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
$forum_list = array();
while ($forum_list[] = $db->fetch_row($result))
;
// Finally, lets loop through the results and output them
for ($i = count($search_set)-1; $i >=0; $i--)
{
_AT_reset($forum_list);
while (list(, $temp) = _AT_each($forum_list))
{
if ($temp[0] == $search_set[$i]['forum_id'])
$forum = '<a href="viewforum.php?id='.$temp[0].'">'.pun_htmlspecialchars($temp[1]).'</a>';
}
$icon = '<div class="icon"><div class="nosize">'.$lang_common['Normal icon'].'</div></div>'."\n";
$icon_text = $lang_common['Normal icon'];
$item_status = '';
$icon_type = 'icon';
$subject = '<a href="viewtopic.php?id='.$search_set[$i]['tid'].'">'.pun_htmlspecialchars($search_set[$i]['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($search_set[$i]['poster']).'</span>';
if ($search_set[$i]['closed'] != '0')
{
$icon_text = $lang_common['Closed icon'];
$item_status = 'iclosed';
}
if (!$pun_user['is_guest'] && $search_set[$i]['last_post'] > $pun_user['last_visit'])
{
$icon_text .= ' '.$lang_common['New icon'];
$item_status .= ' inew';
$icon_type = 'icon inew';
$subject = '<strong>'.$subject.'</strong>';
$subject_new_posts = '<span class="newtext">[ <a href="viewtopic.php?id='.$search_set[$i]['tid'].'&action=new" title="'.$lang_common['New posts info'].'">'.$lang_common['New posts'].'</a> ]</span>';
}
else
$subject_new_posts = null;
$num_pages_topic = ceil(($search_set[$i]['num_replies'] + 1) / $pun_user['disp_posts']);
if ($num_pages_topic > 1)
$subject_multipage = '[ '.paginate($num_pages_topic, -1, 'viewtopic.php?id='.$search_set[$i]['tid']).' ]';
else
$subject_multipage = null;
// Should we show the "New posts" and/or the multipage links?
if (!empty($subject_new_posts) || !empty($subject_multipage))
{
$subject .= ' '.(!empty($subject_new_posts) ? $subject_new_posts : '');
$subject .= !empty($subject_multipage) ? ' '.$subject_multipage : '';
}
?>
<tr<?php if ($item_status != '') echo ' class="'.trim($item_status).'"'; ?>>
<td class="tcl"> <div class="intd">
<div class="<?php echo $icon_type ?>">
<div class="nosize"><?php echo trim($icon_text) ?></div>
</div>
<div class="tclcon"> <?php echo $subject."\n" ?> </div>
</div></td>
<td class="tc2"><?php echo $forum ?></td>
<td class="tc3"><?php echo $search_set[$i]['num_replies'] ?></td>
<td class="tcr"><?php echo '<a href="viewtopic.php?pid='.$search_set[$i]['last_post_id'].'#p'.$search_set[$i]['last_post_id'].'">'.format_time($search_set[$i]['last_post']).'</a> '.$lang_common['by'].' '.pun_htmlspecialchars($search_set[$i]['last_poster']) ?></td>
</tr>
<? } echo "\t\t\t".'</tbody>'."\n\t\t\t".'</table>'."\n\t\t".'</div>'."\n\t".'</div>'."\n".'</div>'."\n\n"; ?>
Merci