Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
4061 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  [PHP] Comment on fé un tableau?

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[PHP] Comment on fé un tableau?

n°353499
real_matho​s
Posté le 05-04-2003 à 11:47:01  profilanswer
 

Salut,
Je voudrais afficher le résultat d'une requête mysql dans deux cellules de tableau différentes. Mais j'ai essayé avec des tableaux HTML, ça fonctionne pas :( Avez-vous la solution? Voici mon code:
 

Code :
  1. <?php
  2. $hote="localhost";
  3. $login="root";
  4. $pass="";
  5. $base="test";
  6. $db = mysql_connect($hote, $login, $pass);
  7. mysql_select_db($base,$db);
  8. $req="SELECT * FROM fichier WHERE versserv='1'";
  9. $res=mysql_query($req) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
  10. while($r = mysql_fetch_array($res)){
  11. $nfichformat = eregi_replace(".zip", "", $r[nfich]);
  12. ?>
  13. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  14.   <tr>
  15.     <td width="75%"><?php echo "<a href=\"./downloadlien.php?iddufichier=$r[idfich]\">$nfichformat</a>"."<BR>\n"; ?></td>
  16.     <td width="25%"><?php echo "$r[poids] KO"."<BR>\n"; }?></td>
  17.   </tr>
  18. </table>

mood
Publicité
Posté le 05-04-2003 à 11:47:01  profilanswer
 

n°353508
real_matho​s
Posté le 05-04-2003 à 12:06:11  profilanswer
 

J'ai fait ça aussi:

Code :
  1. <?php
  2. $hote="localhost";
  3. $login="root";
  4. $pass="";
  5. $base="test";
  6. $db = mysql_connect($hote, $login, $pass);
  7. mysql_select_db($base,$db);
  8. $req="SELECT * FROM fichier WHERE versserv='1'";
  9. $res=mysql_query($req) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
  10. while($r = mysql_fetch_array($res)){
  11. $nfichformat = eregi_replace(".zip", "", $r[nfich]);
  12. echo "<table width="100%" border="0" cellspacing="0" cellpadding="0">
  13.   <tr>
  14.     <td width="75%"><a href=\"./downloadlien.php?iddufichier=$r[idfich]\">$nfichformat</a>"."<BR>\n</td>
  15. <td width="25%">$r[poids] KO"."<BR>\n</td>
  16.   </tr>
  17. </table>";
  18. }
  19. ?>


 
Mais il me met cette erreur:
Parse error: parse error, unexpected T_LNUMBER, expecting ',' or ';' in c:\[...]\testaffich.php on line 18
 
et la ligne 18, c'est ça:

Code :
  1. echo "<table width="100%" border="0" cellspacing="0" cellpadding="0">


 
Alors je comprend pas  :??:


Message édité par real_mathos le 05-04-2003 à 12:08:20
n°353509
HORNY-Gran​dcornu
grumf !
Posté le 05-04-2003 à 12:11:38  profilanswer
 

Si je comprends bien, il s'agit d'une page qui affiche une liste de fichiers destinés à etre téléchargés. ça, ça devrait marcher à coup sur
 

Code :
  1. <html>
  2. <head>
  3. ........blablabla........
  4. </head>
  5. <body>
  6. <table width="100%">
  7. <?php
  8. mysql_connect(blabla) or die("blabla" );
  9. mysql_select_db(blabla) or die("blabla" );
  10. $req=mysql_query("SELECT * FROM fichier WHERE versserv='1'" );
  11. while($a=mysql_fetch_object($req))
  12. {
  13. echo "
  14. <tr>
  15.    <td><a href=\"download.php?id=$a->idfich\">$a->nfich</a></td>
  16.    <td>$a->poids ko</td>
  17. </tr>
  18. ";
  19. }
  20. ?>
  21. </body>
  22. </html>


Message édité par HORNY-Grandcornu le 05-04-2003 à 12:14:10
n°353511
HORNY-Gran​dcornu
grumf !
Posté le 05-04-2003 à 12:13:18  profilanswer
 

C'est simple, tu fais un echo "Texte";
 
Seulement, dans ton texte, il y a des " ! Donc PHP croit que ce qu'il doit afficher est terminé, donc il s'arrete d'afficher mais rencontre du texte qu'il ne peut interpreter... D'où erreur !

n°353513
real_matho​s
Posté le 05-04-2003 à 12:18:40  profilanswer
 

HORNY-GRANDCORNU a écrit :

Si je comprends bien, il s'agit d'une page qui affiche une liste de fichiers destinés à etre téléchargés. ça, ça devrait marcher à coup sur
 

Code :
  1. <html>
  2. <head>
  3. ........blablabla........
  4. </head>
  5. <body>
  6. <table width="100%">
  7. <?php
  8. mysql_connect(blabla) or die("blabla" );
  9. mysql_select_db(blabla) or die("blabla" );
  10. $req=mysql_query("SELECT * FROM fichier WHERE versserv='1'" );
  11. while($a=mysql_fetch_object($req))
  12. {
  13. echo "
  14. <tr>
  15.    <td><a href=\"download.php?id=$a->idfich\">$a->nfich</a></td>
  16.    <td>$a->poids ko</td>
  17. </tr>
  18. ";
  19. }
  20. ?>
  21. </body>
  22. </html>




 
Merci beaucoup j'ai repris ton modèle et ça fonctionne!!! [:tomilou]


Message édité par real_mathos le 05-04-2003 à 12:21:24
n°353520
HORNY-Gran​dcornu
grumf !
Posté le 05-04-2003 à 12:30:30  profilanswer
 

de rien ;)
 
si tu veux plus d'infos sur ce qui se trouve dans le code va sur http://dev.nexen.net , toutes les fonctions y sont détaillées avec exemples à l'appui
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  [PHP] Comment on fé un tableau?

 

Sujets relatifs
[PHP] Dernière case occupée d'un tableau[PHP] Trier un tableau associatif sur le champ de son choix ?
[PHP]Passer un tableau en parametre à l'URL[PHP] Effacer élément d'un tableau multidimentionnel
[ PHP ] comment enlever les doublons d'une var en tableau ( Array )Comparaison de tableau en PHP
[PHP] pb de generation de tableau auto 1 ligne Ok 2eme NaN[PHP] Présentation de données dans un tableau - A à Z
[PHP] Indexer un tableauCreer un tableau un peut particulier en PHP
Plus de sujets relatifs à : [PHP] Comment on fé un tableau?


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)