Voir le sujet précédent :: Voir le sujet suivant |
Auteur |
Message |
cognin frontpage mioche
|
Mise en page tableaux php , Posté le: 19-01-2005 18:09 |
|
|
Bonjour à tous
J'ai un souci de mise en page avec des tableaux créés à partir d'une base de données. Ils se mettent les uns en dessous les autres alors que je dois en avoir 4 côte a côte comme sur l'exemple http://www.seripress.com/test/essaiff4.htm .
De plus les réf. etc... sont alignés en haut alors que je dois les avoir en bas.
Voici mon code
Citation: |
$sql3="SELECT DISTINCT AR_CATA FROM articles";
$valeur=mysql_query($sql3,$db);
while($row_val = mysql_fetch_array($valeur))
{
// $cata prend successivement les valeurs AR_CATA
$cata = $row_val["AR_CATA"];
$indqte = 1;
echo "\t<TABLE border='1'>\r\n";
echo "\t<TR>\r\n";
echo "\t<td>\r\n";
// affichage du type AR_TYPE et de l'image du transfert
echo "\t<TABLE border='1'>\r\n";
echo "\t<TR>\r\n";
echo "\t<td height='12' nowrap class='ref'>".$row_val["AR_CODE"]."</td>\r\n";
echo "\t </tr>\r\n";
echo "\t<TR>\r\n";
echo "\t\t<TD nowrap class='dim'><img src='../_gif/".$row_val["AR_CATA"].".gif' width='130' height='119'></TD>\r\n";
echo "\t </tr>\r\n";
echo "\t<TR>\r\n";
// requete pour recuperer toutes les infos de tous les produits en fonction de leur AR_CATA
$sql2="SELECT * FROM articles WHERE AR_CATA=$cata";
$result2=mysql_query($sql2,$db);
//----- Descriptif du produit en fonction de son AR_CATA --------------------------------------------------------------------------------
echo "\t<TABLE border='1'>\r\n";
echo "\t<TR>\r\n";
echo "\t<td height='12' nowrap class='ref'>Article No.</td>\r\n";
echo "\t<td height='12' nowrap class='ref'>Size in cm</td>\r\n";
echo "\t<td height='12' nowrap class='ref'>Size in inch</td>\r\n";
echo "\t<td height='12' nowrap class='ref'>Price</td>\r\n";
echo "\t<td height='12' nowrap class='ref'>Qty</td>\r\n";
echo "\t </tr>\r\n";
$ligne = 1;
while (($row2 = mysql_fetch_array($result2)) || ($ligne<5)) {
echo "\t<TR>\r\n";
echo "\t<td height='12' nowrap class='ref'>".$row2["AR_CODE"]."</td>\r\n";
echo "\t\t<TD nowrap class='dim'>".$row2["AR_CM"]."</TD>\r\n";
echo "\t\t<TD nowrap class='dim'>".$row2["AR_POUCES"]."</TD>\r\n";
echo "\t\t<TD nowrap class='prix'>".$row2["AR_PRIX"]."\r\n";
echo "\t<td nowrap> <input name='qte".$indqte."' type='text' class='qte' size='2' maxlength='4' value=''></td>\r\n";
echo "\t </tr>\r\n";
$ligne++;
}
echo "\t</TABLE>\r\n";
//-----------------------------------------------------------------------------------------------------------------------------------------
echo "\t </tr>\r\n";
echo "\t</TABLE>\r\n";
echo "\t</td>\r\n";
echo "\t </tr>\r\n";
echo "\t</TABLE>\r\n";
}
?>
|
Même avec mon formateur php nous n'avons pas trouvé la solution. Merci de votre aide
|
|
|
salemioche salemioche
|
Mise en page tableaux php , Posté le: 19-01-2005 21:01 |
|
|
si tu pouvais mettre le html qui en résulte ce serait plus facile... |
|
|
cognin frontpage mioche
|
Mise en page tableaux php , Posté le: 19-01-2005 21:15 |
|
|
salemioche a écrit: |
si tu pouvais mettre le html qui en résulte ce serait plus facile... |
Merci de ton attention. Je suis débutante alors soyez indulgents. Le résultat en HTML est sur le lien que j'ai envoyé. Avant je faisais ce formilaire à la main mais comme maintenant il peut y en avoir 2/300 références il faut que je travaille à partir de la base de données.
Votre aide sera précieuse. Merci encore |
|
|
salemioche salemioche
|
Mise en page tableaux php , Posté le: 19-01-2005 21:23 |
|
|
je voulais dire le html résultant de ta page php, puisque le html 'à la main' est bon, il faudrait pouvoir comparer facilement les différences |
|
|
cognin frontpage mioche
|
Mise en page tableaux php , Posté le: 19-01-2005 22:08 |
|
|
salemioche a écrit: |
je voulais dire le html résultant de ta page php, puisque le html 'à la main' est bon, il faudrait pouvoir comparer facilement les différences |
Merci de ta réponse. Comment faire ? Tout est en local sur mon ordinateur. Je peux te l'envoyer en fichier joint par email. |
|
|
salemioche salemioche
|
Mise en page tableaux php , Posté le: 20-01-2005 8:18 |
|
|
il manque la table globale dans laquelle il y aurait une ligne de 4 cellules
avec un produit par cellule |
|
|
cognin frontpage mioche
|
Mise en page tableaux php , Posté le: 20-01-2005 10:20 |
|
|
Bonjour
Si je comprends bien il faut que je fasse comme en HTML à la main un grand tableau avec 4 petits à l'intérieur c.à.d. 1 Table 100% avec 4 TD 25% ? |
|
|
salemioche salemioche
|
Mise en page tableaux php , Posté le: 20-01-2005 10:24 |
|
|
oui |
|
|
cognin frontpage mioche
|
Mise en page tableaux php , Posté le: 20-01-2005 11:05 |
|
|
merci je vais essayer. Note que c'est mon formateur php qui me l'a fait faire de cette manière. |
|
|
cognin frontpage mioche
|
Mise en page tableaux php , Posté le: 21-01-2005 18:22 |
|
|
Bonsoir,
Eh oui, c'est encore moi et mes tableaux. Rassure toi cela marche !!!!!!!
Toutefois, je ne sais pas comment lui dire de ne mettre que 4 sur une ligne et de recommencer le tout en dessous. En fait il m'en met 4 dans mon tableau principal et le 5ème à coté alors qu'il devrait refaire en tableau principal en dessous du 1er et recommencer le tout etc... J'ai essayé pas mal de choses mais ??????????
Voici le nouveau code
Citation: |
$sql3="SELECT DISTINCT AR_CATA, AR_TYPE FROM articles";
$valeur=mysql_query($sql3,$db);
echo "\t<table border='2' cellpadding='0' cellspacing='0' width='100%'>\r\n";
echo "\t<TR>\r\n";
echo "\t\r\n";
while($row_val = mysql_fetch_array($valeur))
{
// $cata prend successivement les valeurs AR_CATA
$cata = $row_val["AR_CATA"];
$indqte = 1;
echo "\t<td width='25%'><table width='100%' border='1' cellpadding='0' cellspacing='0'>\r\n";
echo "\t<TR>\r\n";
// affichage du type AR_TYPE et de l'image du transfert
echo "\t<td height='40' nowrap colspan='5' class='dim'><div align='center'><p>".$row_val["AR_TYPE"]."</p></div></td>\r\n";
echo "\t</tr>\r\n";
echo "\t<TR>\r\n";
echo "\t<td height='160' nowrap colspan= '5' class='image'><img src='../_gif/".$row_val["AR_CATA"].".gif' width='130' height='119'></td>\r\n";
echo "\t</tr>\r\n";
echo "\t<TR>\r\n";
// requete pour recuperer toutes les infos de tous les produits en fonction de leur AR_CATA
$sql2="SELECT * FROM articles WHERE AR_CATA=$cata";
$result2=mysql_query($sql2,$db);
//----- Descriptif du produit en fonction de son AR_CATA --------------------------------------------------------------------------------
echo "\t<td height='12' nowrap class='dim' readonly=''>Article No.</td>\r\n";
echo "\t<td height='12' nowrap class='dim'>Size in cm</td>\r\n";
echo "\t<td height='12' nowrap class='dim'>Size in inch</td>\r\n";
echo "\t<td height='12' nowrap class='prixtitre' readonly=''>Price</td>\r\n";
echo "\t<td height='12' nowrap class='qte'>Qty</td>\r\n";
echo "\t</tr>\r\n";
$ligne = 1;
while (($row2 = mysql_fetch_array($result2)) || ($ligne<4)) {
echo "\t<TR>\r\n";
echo "\t<td height='12' nowrap class='ref' size='5' maxlength='9' readonly=''>".$row2["AR_CODE"]."</td>\r\n";
echo "\t<TD nowrap class='dim'>".$row2["AR_CM"]."</TD>\r\n";
echo "\t<TD nowrap class='dim'>".$row2["AR_POUCES"]."</TD>\r\n";
echo "\t<TD nowrap class='prix' size='4' maxlength='4' readonly=''>".$row2["AR_PRIX"]."</TD>\r\n";
echo "\t<td nowrap> <input name='qte".$indqte."' type='text' class='qte' size='2' maxlength='4' value=''></td>\r\n";
echo "\t </tr>\r\n";
$ligne++;
}
//-----------------------------------------------------------------------------------------------------------------------------------------
echo "</table>";
echo "</td>";
}
echo "</tr>";
echo "</table>";
echo "<tr>";
|
Merci de votre aide à tous |
|
|
cognin frontpage mioche
|
Mise en page tableaux php , Posté le: 25-01-2005 16:50 |
|
|
cognin a écrit: |
Rebonjour,
quelqu'un a une idée ? Je n'ai toujours pas trouvé la solution
Cordialement
Bonsoir,
Eh oui, c'est encore moi et mes tableaux. Rassure toi cela marche !!!!!!!
Toutefois, je ne sais pas comment lui dire de ne mettre que 4 sur une ligne et de recommencer le tout en dessous. En fait il m'en met 4 dans mon tableau principal et le 5ème à coté alors qu'il devrait refaire en tableau principal en dessous du 1er et recommencer le tout etc... J'ai essayé pas mal de choses mais ??????????
Voici le nouveau code
Citation: |
$sql3="SELECT DISTINCT AR_CATA, AR_TYPE FROM articles";
$valeur=mysql_query($sql3,$db);
echo "\t<table border='2' cellpadding='0' cellspacing='0' width='100%'>\r\n";
echo "\t<TR>\r\n";
echo "\t\r\n";
while($row_val = mysql_fetch_array($valeur))
{
// $cata prend successivement les valeurs AR_CATA
$cata = $row_val["AR_CATA"];
$indqte = 1;
echo "\t<td width='25%'><table width='100%' border='1' cellpadding='0' cellspacing='0'>\r\n";
echo "\t<TR>\r\n";
// affichage du type AR_TYPE et de l'image du transfert
echo "\t<td height='40' nowrap colspan='5' class='dim'><div align='center'><p>".$row_val["AR_TYPE"]."</p></div></td>\r\n";
echo "\t</tr>\r\n";
echo "\t<TR>\r\n";
echo "\t<td height='160' nowrap colspan= '5' class='image'><img src='../_gif/".$row_val["AR_CATA"].".gif' width='130' height='119'></td>\r\n";
echo "\t</tr>\r\n";
echo "\t<TR>\r\n";
// requete pour recuperer toutes les infos de tous les produits en fonction de leur AR_CATA
$sql2="SELECT * FROM articles WHERE AR_CATA=$cata";
$result2=mysql_query($sql2,$db);
//----- Descriptif du produit en fonction de son AR_CATA --------------------------------------------------------------------------------
echo "\t<td height='12' nowrap class='dim' readonly=''>Article No.</td>\r\n";
echo "\t<td height='12' nowrap class='dim'>Size in cm</td>\r\n";
echo "\t<td height='12' nowrap class='dim'>Size in inch</td>\r\n";
echo "\t<td height='12' nowrap class='prixtitre' readonly=''>Price</td>\r\n";
echo "\t<td height='12' nowrap class='qte'>Qty</td>\r\n";
echo "\t</tr>\r\n";
$ligne = 1;
while (($row2 = mysql_fetch_array($result2)) || ($ligne<4)) {
echo "\t<TR>\r\n";
echo "\t<td height='12' nowrap class='ref' size='5' maxlength='9' readonly=''>".$row2["AR_CODE"]."</td>\r\n";
echo "\t<TD nowrap class='dim'>".$row2["AR_CM"]."</TD>\r\n";
echo "\t<TD nowrap class='dim'>".$row2["AR_POUCES"]."</TD>\r\n";
echo "\t<TD nowrap class='prix' size='4' maxlength='4' readonly=''>".$row2["AR_PRIX"]."</TD>\r\n";
echo "\t<td nowrap> <input name='qte".$indqte."' type='text' class='qte' size='2' maxlength='4' value=''></td>\r\n";
echo "\t </tr>\r\n";
$ligne++;
}
//-----------------------------------------------------------------------------------------------------------------------------------------
echo "</table>";
echo "</td>";
}
echo "</tr>";
echo "</table>";
echo "<tr>";
|
Merci de votre aide à tous |
|
|
|
salemioche salemioche
|
Mise en page tableaux php , Posté le: 25-01-2005 17:00 |
|
|
Code: |
$ligne = 1;
while (($row2 = mysql_fetch_array($result2))) {
echo "\t<TR>\r\n";
echo "\t<td height='12' nowrap class='ref' size='5' maxlength='9' readonly=''>".$row2["AR_CODE"]."</td>\r\n";
echo "\t<TD nowrap class='dim'>".$row2["AR_CM"]."</TD>\r\n";
echo "\t<TD nowrap class='dim'>".$row2["AR_POUCES"]."</TD>\r\n";
echo "\t<TD nowrap class='prix' size='4' maxlength='4' readonly=''>".$row2["AR_PRIX"]."</TD>\r\n";
echo "\t<td nowrap> <input name='qte".$indqte."' type='text' class='qte' size='2' maxlength='4' value=''></td>\r\n";
$ligne++;
if ( $ligne >= 4 ) { $ligne = 1 ; echo "\t </tr>\r\n<tr>"; }
}
echo "</tr>";
|
j'ai pas testé mais ca me parait mieux... |
|
|
cognin frontpage mioche
|
Mise en page tableaux php , Posté le: 25-01-2005 17:37 |
|
|
Merci beaucoupe de ton aide. J'ai testé mais cela ne marche toujours pas. Je t'ai envoyé le résultat par email pour que tu te rende mieux compte.
Cordialement |
|
|
salemioche salemioche
|
Mise en page tableaux php , Posté le: 25-01-2005 17:52 |
|
|
je me suis trompé de while, c'est sur celui du haut qu'il faut gérer le coup de lign=1 puis ligne=4 |
|
|
cognin frontpage mioche
|
Mise en page tableaux php , Posté le: 25-01-2005 18:08 |
|
|
Cela me donne un message d'erreur
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp\www\seripress\essais\vieux trucs\test10.php on line 66
et il n'y a plus qu'un seul tableau qui s'affiche à moitié (juste celui avec les titres des colonnes). |
|
|
|