Generer des données en format .txt

Fermé
roland999 Messages postés 32 Date d'inscription dimanche 27 octobre 2013 Statut Membre Dernière intervention 18 février 2014 - 29 janv. 2014 à 10:59
mpmp93 Messages postés 6648 Date d'inscription mercredi 13 avril 2011 Statut Membre Dernière intervention 28 septembre 2015 - 29 janv. 2014 à 20:31
salut.. j'ai besoin d'une aide pour terminer mon travail
au fait je veux génére un fichier en format txt et je sai pas comment faire voici mon code

code
<head><script language="Javascript">
function imprimer(){window.print();}
</script></head>
<body marginheight="20" bgcolor="white">
<table width="100%" border="0">
<tr>
<td width="49%"><input name="imprimer" onClick="imprimer()" type="button" value="Imprimer cette page"></td>
<td width="51%" align="right"><a href="clientsmenu.php" class="Style11">RETOUR</a></td>
</tr>
</table>

<div id="header"><img src="images/logo.png" width="329" height="157" />
<div id="bande"></div>
<div id="heure">
</div></div>
</div>
<?php
//requête de travail
$requete = "SELECT * FROM clients";
$resultat = mysql_query($requete) or die(mysql_error());
?>
<table width="98%" border="0" align="center">
<tr>
<td colspan="3" align="center" valign="baseline"><span class="Style10">=================================</span></td>
</tr>
<tr>
<td width="37%" align="right" valign="middle"><span class="Style10">===============================</span></td>
<td width="26%" align="center" valign="top"><span class="Style9">Liste des clients</span></td>
<td width="37%" valign="middle"><span class="Style10">===============================</span></td>
</tr>
<tr>
<td colspan="3" align="center" valign="top"><span class="Style10">=================================</span></td>
</tr>
</table>

<TABLE width="1294" border="1" class="tableau">
<tr class="style3">
<th width="110" align="center">Numéro de police</th>
<th width="83" align="center">Nom</th>
<th width="153" align="center">Prénoms</th>
<th width="99" align="center">Nationnalité</th>
<th width="60" align="center">Sexe</th>
<th width="124" align="center">Adresse</th>
<th width="86" align="center">D.S.C</th>
<th width="117" align="center">Date de naissance</th>
<th width="121" align="center">Lieu de naissance</th>
<th width="106" align="center">Code de l'agent</th>
<th width="82" align="center">Modification</th>
<th width="77" align="center">Suppression</th>
</tr>
<?php
while ($row=mysql_fetch_row($resultat))
{
echo "<tr>";
echo "<td align=\"center\">$row[0]</td>";
echo "<td align=\"center\">$row[1]</td>";
echo "<td align=\"center\">$row[2]</td>";
if( !empty($row[3]) )
echo "<td align=\"center\">$row[3]</td>";
else
echo "<td align=\"center\">---</td>";
if( !empty($row[4]) )
echo "<td align=\"center\">$row[4]</td>";
else
echo "<td align=\"center\">---</td>";
if( !empty($row[5]) )
echo "<td align=\"center\">$row[5]</td>";
else
echo "<td align=\"center\">---</td>";
if( !empty($row[6]) )
echo "<td align=\"center\">$row[6]</td>";
else
echo "<td align=\"center\">---</td>";
if( !empty($row[7]) )
echo "<td align=\"center\">$row[7]</td>";
else
echo "<td align=\"center\">---</td>";
if( !empty($row[8]) )
echo "<td align=\"center\">$row[8]</td>";
else
echo "<td align=\"center\">---</td>";
if( !empty($row[9]) )
echo "<td align=\"center\">$row[9]</td>";
else
echo "<td align=\"center\">---</td>";
echo "<td align=\"center\"><a href=modifierclient.php?code=$row[0] target=\"bas\"><img src=\"images/modifier.jpg\"></a></td>";
echo "<td align=\"center\"><a href=supprimerclient.php?code=$row[0] target=\"bas\"><img src=\"images/supprimer.jpg\"></a></td>";
echo "<tr>";
}
?>
</table></div>
</body>

aidez moi a mettre ces données dans un fichier txt
A voir également:

1 réponse

mpmp93 Messages postés 6648 Date d'inscription mercredi 13 avril 2011 Statut Membre Dernière intervention 28 septembre 2015 1 340
29 janv. 2014 à 20:31
Bonsoir,

Vous êtes un peu lord, là.....

Vous avez déja posté cette question et on vous a répondu:
https://forums.commentcamarche.net/forum/affich-29596403-generer-un-fichier-au-format-txt-a-partir-d-une-base-de-donnees

Je vous ai même mis un lien:
la solution ici:
https://www.php.net/manual/fr/function.file-put-contents.php

C'est facile comme tout. On va pas faire le boulot à votre place et s'infuser toute la quincaillerie HTML autour du PHP.

Merci.



A+
0