Fwrite très vite incompréhensible

Résolu
Étienne9 Messages postés 1090 Statut Membre -  
Étienne9 Messages postés 1090 Statut Membre -
Bonjour à tous,

Y a t-il moyen de créer le code d'une page de manière simple car ça devient très vitre incompréhensible.
Il n'y a pas un convertisseur de code vers un fwrite ?

Petite démonstration :

  fwrite($id_file,"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-15\">\n");  
  fwrite($id_file,"<link rel=\"stylesheet\" type=\"text/css\" href=\"../../document.css\">\n");  
  fwrite($id_file,"<html>\n");  
  fwrite($id_file,"<?php \ninclude '../../sql/connex.inc.php';\n\$idcom=connex(\"naden\",\"../../sql/myparam\");\n");  
  fwrite($id_file,"\$result = mysqli_query(\$idcom,\"Select * from ajout where Num='".$num."'\");\n");  
  fwrite($id_file,"\$result2 = mysqli_query(\$idcom,\"Select nom,prenom,pseudo,mail,points,cp from personne where pseudo='".$_SESSION['pseudo']."'\");\n");  
  fwrite($id_file,"if ((\$result) && (\$result2)) {\n");  
  fwrite($id_file,"\$result2 = mysqli_fetch_array(\$result2);\n");  
  fwrite($id_file,"\$result = mysqli_fetch_array(\$result);\n");  
  fwrite($id_file,"echo \"<head><title>Annonce numéro \$result[6] - \$result[1]</title></head>\";\n");  
  fwrite($id_file,"echo \"<body>\";\n");  
  fwrite($id_file,"echo \"<h1 align=\\\"center\\\">"."Annonce numéro \$result[6] - \$result[1]</h1>\";\n");  
  fwrite($id_file,"echo \"<table align=\\\"center\\\" height=\\\"70%\\\" \\\" width=\\\"70%\\\"><tr>\";\n");  
  fwrite($id_file,"\$tab = glob(\"../photos/$num.*\");\n");  
  fwrite($id_file, "echo \" <td width=\\\"70%\\\"><h2>État : \$result[0]</h2><img width=\\\"70%\\\" src=\\\"\".\$tab[0].\"\\\"></td>\";\n");  
  fwrite($id_file, "echo \"<td rowspan=\\\"2\\\">Date création : \$result[2]<br>Nom : \$result2[0]<br>Prénom : \$result2[1]<br>Pseudo : \$result2[2]<br>Adresse Mail : \$result2[3]<br>Points : \$result2[4]<br>Code Postal: \$result2[5]\";\n");  
  fwrite($id_file,"echo \"<br><br>");  
  fwrite($id_file,"</tr>\";\n");  
  fwrite($id_file,"echo \"<tr><td align=\\\"right\\\"><h2>Prix : \$result[4]€</h2>\";\n");  
  fwrite($id_file, "if (\$result[0] == 'Enchère') { \n echo \" de \$result[9]\";\n }\n");  
  fwrite($id_file,"echo \"</td></tr>\";\n");  
  fwrite($id_file, "echo \"<tr><td colspan=\\\"2\\\">\";\n");  
  fwrite($id_file,"echo \" Description :\".nl2br(\$result[5]).\"</td></tr>\";\n");  
  fwrite($id_file,"echo \"</td></tr></table>\";\n");  
  fwrite($id_file,"echo \"</body>\";\n");  
  fwrite($id_file,"echo \"</html>\";\n");  
  fwrite($id_file,"mysqli_close(\$idcom);\n");  
  fwrite($id_file,"} else { echo \"Erreur accès base de données\";}\n?>\n");  
  fclose($id_file);  

3 réponses

Utilisateur anonyme
 
Salut salut,

Un convertisseur de code.. Je ne connais pas.
Peut être que si tu fais une unique chaine str en la concaténant tu peux mieux ordonner le code ( ce sera peut être plus lisible)
1
jeremy.s Messages postés 1248 Statut Membre 79
 
Dans quel but veux tu metter tout ca dans un fichier ?
1
Étienne9 Messages postés 1090 Statut Membre 49
 
En fait j'ai été idiot, au lieu de créer une page à chaque annonce créée j'ai fait une seule et uniquement page et je mets le numéro de l'annonce à afficher dans $_GET['num']
0