Voici mon code qui me permet d'afficher mon tableau
<?php
// Fonction pour construire une table à partir des résultat de la requête
function buildClodoTable($where='') {
// Construire la requete
$query = "SELECT clodo,att,def,fightvalue,habilite,attaque,defense,maj, date_format(maj,'%Y-%m-%d') lastmaj
FROM membre ORDER BY fightvalue DESC";
// Executer la requete
$result = mysql_query($query) or die('Erreur SQL !<br>'.$result.mysql_error());
if ($result==false) {
// on p'tit message d'erreur sympa indiquant que ça a merdé pourrait être appréciable (plutôt qu'une page blanche) <img src="./images/smilies/icon_smile.gif" alt=":)" title="Smile" />
echo mysql_error();
}
$lines = '';
$now = new DateTime(date('Y-m-d'));
while ($row = mysql_fetch_array($result)) {
$lastmaj = new DateTime($row['lastmaj']);
$interval = $lastmaj->diff($now);
if( $interval->format('%d') >= 7)$style = 'background-color:red';
else $style = '';
$lines .= '
<tr style="'.$style.'">
<td>'.$row['clodo'].'</td>
<td>'.$row['att'].'</td>
<td>'.$row['def'].'</td>
<td>'.$row['fightvalue'].'</td>
<td>'.$row['habilite'].'</td>
<td>'.$row['attaque'].'</td>
<td>'.$row['defense'].'</td>
<td>'.$row['maj'].'</td>
</tr>';
}
return '
<table border="1" cellpadding=5 cellspacing=5 height=50>
<tr>
<th class="name"> Nom clodo </th>
<th> ATT </th>
<th> DEF </th>
<th> Fightvalue </th>
<th> habilité </th>
<th> attaque </th>
<th> défense </th>
<th> MAJ </th>
</tr>'.$lines.'
</table>';
}
//Construire le tableau à partir du résultat de la requête
$table = buildClodoTable("");
echo $table;
}
?>
Je pense avoir fais le tour du code mais je ne comprend pas pourquoi ca ne fonctionne pas