Probleme d'affichage php
Résolu
maff
-
maff -
maff -
Bonjour,
alors voila j'ai un tableau php asser monstrueux(et je ne peut pas le faire autrement patron oblige) et je doit afficher se tableau en html jai reussi à l'afficher mais pas correctement voici mon code de tableau :
$i=0;
$j=0;
$tab['commande'][$i]['titre']='ajout';
$tab['commande'][$i]['descriptif_commande']='ajoute_utilisateur';
$tab['commande'][$i]['argument'][$j]['type']='caractere';
$tab['commande'][$i]['argument'][$j]['nom']='nom';
$tab['commande'][$i]['argument'][$j]['description']='nom_utilise';
$tab['commande'][$i]['argument'][$j]['value_defaut']='';
$j++;
$tab['commande'][$i]['argument'][$j]['type']='int';
$tab['commande'][$i]['argument'][$j]['nom']='ip';
$tab['commande'][$i]['argument'][$j]['description']='adresse_ip';
$tab['commande'][$i]['argument'][$j]['value_defaut']='127.0.0.1';
$j++;
$tab['commande'][$i]['argument'][$j]['type']='caractere';
$tab['commande'][$i]['argument'][$j]['nom']='domaine';
$tab['commande'][$i]['argument'][$j]['description']='domain_utilisee';
$tab['commande'][$i]['argument'][$j]['value_defaut']='test.fr';
$j++;
$tab['commande'][$i]['argument'][$j]['type']='int';
$tab['commande'][$i]['argument'][$j]['nom']='used';
$tab['commande'][$i]['argument'][$j]['description']='nom_utilise';
$tab['commande'][$i]['argument'][$j]['value_defaut']='0';
et mon code daffichage :
echo("<table border=2>");
foreach($tab['commande'] as $commande)
{
foreach($commande['argument'] as $arg)
{
echo('<tr><td rowspan="1">'.$commande['titre'].'</td><td rowspan="1">'.$commande['descriptif_commande'].'</td><td rowspan="1">'.$arg['nom'].'</td><td rowspan="1">'.$arg['value_defaut'].'</td><td rowspan="1">'.$arg['description'].'</td></tr>');
}
}
echo("</TABLE>");
en gros il me repete 4 les $commande['titre']. et aussi $commande['descriptif_commande'].
comment faire pour qu'il ne laffiche qu'une seul fois
merci d'avance
alors voila j'ai un tableau php asser monstrueux(et je ne peut pas le faire autrement patron oblige) et je doit afficher se tableau en html jai reussi à l'afficher mais pas correctement voici mon code de tableau :
$i=0;
$j=0;
$tab['commande'][$i]['titre']='ajout';
$tab['commande'][$i]['descriptif_commande']='ajoute_utilisateur';
$tab['commande'][$i]['argument'][$j]['type']='caractere';
$tab['commande'][$i]['argument'][$j]['nom']='nom';
$tab['commande'][$i]['argument'][$j]['description']='nom_utilise';
$tab['commande'][$i]['argument'][$j]['value_defaut']='';
$j++;
$tab['commande'][$i]['argument'][$j]['type']='int';
$tab['commande'][$i]['argument'][$j]['nom']='ip';
$tab['commande'][$i]['argument'][$j]['description']='adresse_ip';
$tab['commande'][$i]['argument'][$j]['value_defaut']='127.0.0.1';
$j++;
$tab['commande'][$i]['argument'][$j]['type']='caractere';
$tab['commande'][$i]['argument'][$j]['nom']='domaine';
$tab['commande'][$i]['argument'][$j]['description']='domain_utilisee';
$tab['commande'][$i]['argument'][$j]['value_defaut']='test.fr';
$j++;
$tab['commande'][$i]['argument'][$j]['type']='int';
$tab['commande'][$i]['argument'][$j]['nom']='used';
$tab['commande'][$i]['argument'][$j]['description']='nom_utilise';
$tab['commande'][$i]['argument'][$j]['value_defaut']='0';
et mon code daffichage :
echo("<table border=2>");
foreach($tab['commande'] as $commande)
{
foreach($commande['argument'] as $arg)
{
echo('<tr><td rowspan="1">'.$commande['titre'].'</td><td rowspan="1">'.$commande['descriptif_commande'].'</td><td rowspan="1">'.$arg['nom'].'</td><td rowspan="1">'.$arg['value_defaut'].'</td><td rowspan="1">'.$arg['description'].'</td></tr>');
}
}
echo("</TABLE>");
en gros il me repete 4 les $commande['titre']. et aussi $commande['descriptif_commande'].
comment faire pour qu'il ne laffiche qu'une seul fois
merci d'avance
A voir également:
- Probleme d'affichage php
- Affichage double ecran - Guide
- Easy php - Télécharger - Divers Web & Internet
- Problème affichage fenêtre windows 10 - Guide
- Windows 11 affichage classique - Guide
- Thunderbird problème affichage message - Forum Thunderbird
3 réponses
echo("<table border=2>");
foreach($tab['commande'] as $commande)
{
echo'<tr><td rowspan="4">'.$commande['titre'].'</td><td rowspan="4">'.$commande['descriptif_commande'];
foreach($commande['argument'] as $arg)
{
echo'</td><td rowspan="1">'.$arg['nom'].'</td><td rowspan="1">'.$arg['value_defaut'].'</td><td rowspan="1">'.$arg['description'].'</td></tr>';
}
}
echo("</TABLE>");
voili voila...
4 parce qu'il y a 4 lignes dans ton array....
Par contre, si tu ne sais pas combien il y en as... alors il faut utiliser autre chose
foreach($tab['commande'] as $commande)
{
echo'<tr><td rowspan="4">'.$commande['titre'].'</td><td rowspan="4">'.$commande['descriptif_commande'];
foreach($commande['argument'] as $arg)
{
echo'</td><td rowspan="1">'.$arg['nom'].'</td><td rowspan="1">'.$arg['value_defaut'].'</td><td rowspan="1">'.$arg['description'].'</td></tr>';
}
}
echo("</TABLE>");
voili voila...
4 parce qu'il y a 4 lignes dans ton array....
Par contre, si tu ne sais pas combien il y en as... alors il faut utiliser autre chose
c deja beaucoup mieux merci mais c pas encore sa ^^ en fait je doit avoir 4 ligne dans mon premier array pui apres 3
c'est bon je me sui sortit en faisant sa
echo("<table border=2>");
echo("<tr><th>commande</th><th>descriptif commande</th><th>arguments</th><th>valeur argument</th><th>descriptif argument</th></tr>");
foreach($tab['commande'] as $commande)
{
if($commande['titre']=='ajout')
{
echo('<tr><td rowspan="4">'.$commande['titre'].'</td><td rowspan="4">'.$commande['descriptif_commande']);
}
else
{
echo('<tr><td rowspan="3">'.$commande['titre'].'</td><td rowspan="3">'.$commande['descriptif_commande']);
}
foreach($commande['argument'] as $arg)
{
echo'</td><td rowspan="1">'.$arg['nom'].'</td><td rowspan="1">'.$arg['value_defaut'].'</td><td rowspan="1">'.$arg['description'].'</td></tr>';
}
}
echo("</TABLE>");
merci en tt cas peace
echo("<table border=2>");
echo("<tr><th>commande</th><th>descriptif commande</th><th>arguments</th><th>valeur argument</th><th>descriptif argument</th></tr>");
foreach($tab['commande'] as $commande)
{
if($commande['titre']=='ajout')
{
echo('<tr><td rowspan="4">'.$commande['titre'].'</td><td rowspan="4">'.$commande['descriptif_commande']);
}
else
{
echo('<tr><td rowspan="3">'.$commande['titre'].'</td><td rowspan="3">'.$commande['descriptif_commande']);
}
foreach($commande['argument'] as $arg)
{
echo'</td><td rowspan="1">'.$arg['nom'].'</td><td rowspan="1">'.$arg['value_defaut'].'</td><td rowspan="1">'.$arg['description'].'</td></tr>';
}
}
echo("</TABLE>");
merci en tt cas peace