CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

Problème PHP

sheva-mafioso
sheva-mafioso
Niveau 10
16 avril 2005 à 19:15:27

Bonsoir,

Je débute en PHP et j´essaye de classer une liste de morceaux avec le nom des albums.

Mon essai est ici : http://guitarsheva.free.fr/test/index2.php

Mon problème est que je ne veux pas que " Morceau" et " Album" se répète à chaque fois.

Le code source :

< ?
mysql_connect("sql.free.fr", " guitarsheva", " md^p");
mysql_select_db("guitarsheva");

$reponse = mysql_query("SELECT * FROM morceaux ORDER BY nom");

while ( $donnees = mysql_fetch_array($reponse) )
{
? >

< table width="877" border="0" cellspacing="0" cellpadding="0">
< tr>
< td width="364" height="19" valign="top"><div align="center"><strong><font size="2"
face="Verdana">Morceau</font></strong></div></td>

< td width="513" valign="top"><div align="center"><strong><font size="2" face="Verdana">Album</font></strong></div></td>
< /tr>
< tr>
< td width="364" height="19" valign="top"><div align="justify"><font size="2"><font face="Verdana"><? echo $donnees[´nom´]; ? ></font></font></div></td>
< td height="19" valign="top"><div align="justify"><font size="2" face="Verdana"><? echo $donnees[´album´]; ? >
</font></div></td>
< /tr>
< /table>

< ?
}

mysql_close();
? >

Voilà, merci par avance.

MathieuN7
MathieuN7
Niveau 10
16 avril 2005 à 19:29:49

Salut,

Il faut que tu changes ta boucle, au lieu de faire répéter l´affichage du tableau complet, affiche d´abord la première ligne ( Album et Morceau ) , puis tu fais une bouce qui ajoutera une ligne au forum à chaque fois.
En gros, le tableau commence avant la boucle et se termine après.

sheva-mafioso
sheva-mafioso
Niveau 10
16 avril 2005 à 19:43:02

ok

maintenant ca me fait :
http://guitarsheva.free.fr/test/index3.php

le code :

< ?
mysql_connect("sql.free.fr", " guitarsheva", " mdp");
mysql_select_db("guitarsheva");

$reponse = mysql_query("SELECT * FROM morceaux ORDER BY nom");

? >

< table width="877" border="1" cellspacing="0" cellpadding="0">
< tr>
< td width="364" height="19" valign="top"><div align="center"><strong><font size="2"
face="Verdana">Morceau</font></strong></div></td>

< td width="513" valign="top"><div align="center"><strong><font size="2" face="Verdana">Album</font></strong></div></td>
< /tr>

< tr>

< ? while ( $donnees = mysql_fetch_array($reponse) )
{
? >

< td width="364" height="19" valign="top"><div align="justify"><font size="2" face="Verdana">

<? echo $donnees[´nom´]; ? ></font></div></td>
< td height="19" valign="top"><div align="justify"><font size="2" face="Verdana"><? echo $donnees[´album´]; ? >
</font></div></td>
< /tr>
< /table>

< ?
}

mysql_close();
? >

MathieuN7
MathieuN7
Niveau 10
16 avril 2005 à 19:47:01

Pas tout à fait:

< ?
mysql_connect("sql.free.fr", " guitarsheva", " mdp");
mysql_select_db("guitarsheva");

$reponse = mysql_query("SELECT * FROM morceaux ORDER BY nom");

? >

< table width="877" border="1" cellspacing="0" cellpadding="0">
< tr>
< td width="364" height="19" valign="top"><div align="center"><strong><font size="2"

face="Verdana">Morceau</font></strong></div></td>

< td width="513" valign="top"><div align="center"><strong><font size="2" face="Verdana">Album</font></strong></div></td>
< / tr>

< ? while ( $donnees = mysql_fetch_array($reponse) )
{
? >
< tr>
< td width="364" height="19" valign="top"><div align="justify"><font size="2" face="Verdana">

< ? echo $donnees[´nom´]; ? > </font></div></td>
< td height="19" valign="top"><div align="justify"><font size="2" face="Verdana"><? echo $donnees[´album´]; ? >
< /font></div></td>
< / tr>

< ?
}
echo ´< / table>´;

mysql_close();
? >

sheva-mafioso
sheva-mafioso
Niveau 10
16 avril 2005 à 20:43:28

désolé mais ca fait une erreur...

Merci quand même

sheva-mafioso
sheva-mafioso
Niveau 10
16 avril 2005 à 21:22:22

. ..siouplé...

sheva-mafioso
sheva-mafioso
Niveau 10
16 avril 2005 à 21:49:54

c´est plus la peine, merci quand meme !

MathieuN7
MathieuN7
Niveau 10
16 avril 2005 à 21:52:33

Attends, ça fait une erreur, je ne t´ai pas parlé de faire un copier/coller ! Je n´ai fait que prendre ton code pour replacer grosso modo les balises clé ! Je pense que tu connais assez le PHP pour ne pas faire d´erreurs de syntaxe :)

sheva-mafioso
sheva-mafioso
Niveau 10
16 avril 2005 à 22:40:25

nan j´ai vérifié et tout mais c´est bon maintenant, j´ai trouvé comment faire !

MathieuN7
MathieuN7
Niveau 10
16 avril 2005 à 23:01:23

oki :)
En tous cas, la méthode que je t´ai dite, c´est celle que j´utilise toujours ! :)

Comment as-tu fait ?

sheva-mafioso
sheva-mafioso
Niveau 10
17 avril 2005 à 12:58:44

< ?
mysql_connect("localhost", " guitarsheva", " mdp");
mysql_select_db("guitarsheva");

$retour = mysql_query("SELECT COUNT(*) AS nbre_entrees FROM songs_offs");
$donnees = mysql_fetch_array($retour);
? >

< font face=Verdana size=2>Je joue < ? echo $donnees[´nbre_entrees´]; ? > songs de The Offspring ! </font>

< ?
mysql_close();
? >
< br><br>
< ?php
mysql_connect("sql.free.fr", " guitarsheva", " mdp");
mysql_select_db("guitarsheva");

$reponse = mysql_query("SELECT * FROM songs_offs ORDER BY nom");
? >

< table width="877" border="1" cellspacing="0" cellpadding="0">
< tr>
< td width="364" height="19" valign="top"><div align="center"><strong><font size="2"
face="Verdana">Morceau</font></strong></div></td>

< td width="513" valign="top"><div align="center"><strong><font size="2" face="Verdana">Album</font></strong></div></td>
< /tr>

< ?php
while($donnees=mysql_fetch_array($reponse) )
{
? >

< tr>
< td width="364" height="19" valign="top"><div align="justify"><font size="2" face="Verdana"><? echo $donnees[´nom´]; ? ></font></div></td>
< td height="19" valign="top"><div align="justify"><font size="2" face="Verdana"><? echo $donnees[´album´]; ? ></font></div></td>
< /tr>

< ?php
}
? >

< /table>

< ?php
mysql_close();
? >

J´ai juste rajouté un pti truc pour compter le nombre de morceaux.

Sous forums
  • Aide à l'achat Mac
  • Création de Jeux
  • Linux
  • Création de sites web
  • Programmation
  • Internet
  • Steam Deck
  • Macintosh
  • Hardware
La vidéo du moment