Affichage des enregistrements dans un tableau

Fermé
bilane Messages postés 13 Date d'inscription samedi 2 septembre 2006 Statut Membre Dernière intervention 21 mars 2007 - 12 mars 2007 à 06:27
Dalida Messages postés 6728 Date d'inscription mardi 14 mai 2002 Statut Contributeur Dernière intervention 11 janvier 2016 - 12 mars 2007 à 11:36
Bonjour,
J’ai un problème d’affichage si vous pouvez m’aider.
Je voulais afficher mes enregistrements sur forme d’un tableau de 3lignes et 4 colonnes.
Mais la cellule (1,4) reste vide et il y a un quatrième ligne qui s’affiche.

Voici le code :

<?php require('connect.php.inc');
$db=connect(); ?>

<body>

<div id="corps">
<p><?php include("titre.php"); ?></p>
<p>       </p>
<p><?php


$an=2006;

echo " ANNEE ".$an."<br><br>";


$req = mysql_query("SELECT DISTINCT num_jo, date_jo, type_jo FROM jo where DATE_FORMAT(date_jo,'%Y')='$an' ORDER BY date_jo ASC;");
$res = mysql_num_rows($req);
$i=0; $mois = ""; $j=0; $lien = "";

$nb_col = 4;
$k=0;

echo '<table id="tabjo" width="75%" border="1" cellspacing="0" align="center">';
WHILE ($i < $res){

$num = mysql_result($req,$i,"num_jo");
$type = mysql_result($req,$i,"type_jo");
$dat = mysql_result($req,$i,"date_jo");
list($year, $month, $day) = explode("-", $dat);
$months = array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
"Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre");
$aux = $months[$month-1];

if ($k==$nb_col) {
echo "</tr>";
$k=0;
}
if ($k==0) {
echo "<tr>";
}

if ($aux != $mois) { if ($mois != '') echo "<td valign='top' align='center' width=33% height=1 ><font color='blue'>".$mois."<br><br>".$lien."</font></td>"; $mois = $aux; $lien = ""; $k++;}

if ( $type == "n")
{$lien .= '<a href=jof.php?n='.$num.'&type='.$type.'&date='.$dat.'> n° '.$num.'</a><br>'; }
else { if ( $type == "sp")
{$lien .= '<a href=jof.php?n='.$num.'&type='.$type.'&date='.$dat.'> spécial n° '.$num.'</a><br>'; }
else { if ( $type == "spelec")
{$lien .= '<a href=jof.php?n='.$num.'&type='.$type.'&date='.$dat.'>spécial élecion n° '.$num.'</a><br>'; }
else { if ( $type == "spreg")
{$lien .= '<a href=jof.php?n='.$num.'&type='.$type.'&date='.$dat.'> spécial élection régional n° '.$num.'</a><br>'; }
else { if ( $type == "excep")
{$lien .= '<a href=jof.php?n='.$num.'&type='.$type.'&date='.$dat.'> exceptionnel n° '.$num.'</a><br>'; }}}}}


$i++;

} echo "<td valign='top' align='center' width=33% height=1><font color='blue'>".$mois. "<br><br>".$lien."</td></font>";
if ($k>0 && $k<$nb_col) {
while ($k<$nb_col) {
echo "<td> </td>";
$k++;
}
echo "</tr>";
}
echo '</table> <br><br><br> ';
mysql_close();
?>


merci d'avance.

1 réponse

Dalida Messages postés 6728 Date d'inscription mardi 14 mai 2002 Statut Contributeur Dernière intervention 11 janvier 2016 920
12 mars 2007 à 11:36
salut,

excellente idée ce deuxième post pour un même problème !
et si tu ne daignes pas répondre à mes questions, tu peux même en ouvrir un troisième !
0