Forum » » Le coin des codeurs » » [Résolu] - array à 3 champs
Posté : 25 janv. 2009 à 12:06
<?php
$connect = mysql_connect('localhost', 'root', '');
mysql_select_db('lansou', $connect);
$retour_util = mysql_query("SELECT casetabl, posicase, imags FROM ".$NPDS_Prefix."tech_tab WHERE cateID = 4 ORDER BY casetabl ASC");
$nb_resultat = mysql_num_rows($retour_util);
$utilisateurs = array();
while ($donnees_util = mysql_fetch_assoc($retour_util))
{
$casetabl = $donnees_util['casetabl'];
$posicase = $donnees_util['posicase'];
$imags = $donnees_util['imags'];
/*Modif de Hotfirenet
Ton tableau n'ete pas bien construit par rapport a ce que tu voulais
Remplacement de :
$utilisateurs[] = array('case' => $casetabl, 'fiche' => $posicase, 'imags' => $imags);
par :
*/
$utilisateurs[$casetabl] = array('fiche' => $posicase, 'imags' => $imags);
}
print_r($utilisateurs);
////////////////////////////////////////////////////////////////////
/// la variable casetable doit correspondre à la variable $num1 ///
////////////////////////////////////////////////////////////////////
$col1 = 5; $lign1 = 5;
$long1 = 100 * $col1 + 10;
echo '<div style="width: '.$long1.'px;margin-left: auto;margin-right: auto;border: #000 1px solid;text-align:center;">';
$num1 = 1;
for ($t = 1; $t <= ($col1); $t++)
{
echo '<div>';
for ($s = 1; $s <= ($lign1); $s++)
{
//Utilisation du tableau
echo '<div style="float:left;width:100px;height:30px;border: #ff0000 1px solid;">'.$utilisateurs[$num1]['imags'].'</div>';
$num1 ++;
}
echo '</div><br clear="all" />';
}
echo '</div>';
?>
Cet article provient de NPDS
https://www.npds.org/viewtopic.php?topic=24139&forum=5