1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
| <div class="container-fluid">
<form method="POST">
<br>
<button name="modifier" class="btn btn-primary" style="float: right;">Modifier</button>
<p style="float: right;"> </p>
<select style="float:right;" name="fichierEnregistre" id="filename" action="">
<?php
//--------------------------------------------------------------------------------//
// Parcours dans dossier tous les fichiers CSV, afin de les afficher dans la combo
$fichiers = glob('fichiers/*.csv');
foreach($fichiers as $fichier)
{
$fichier1 = basename($fichier); ?>
<option><?php echo $fichier1 ?></option>
<?php
}
?>
</select>
<?php
if(isset($_POST['modifier']))
{ ?>
<!-- Affiche le nombre de lignes du tableau -->
<div id="dvData">
<table class="table table-striped" id="makeEditable">
<thead class="thead-inverse">
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th>t</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<!-- On retourne false afin que le bouton ne recharge pas la page -->
<button id="but_add" onclick="javascript:return false;">Ajouter une ligne</button>
</tr>
</thead>
<tbody>
<?php
$row = 1;
if (($handle = fopen("fichiers/" .$_POST['fichierEnregistre'], "r+")) !== FALSE)
{
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE)
{
$num = count($data);
$row++;
?>
<tr>
<?php
?>
<td><?php echo $data[0]; ?></td>
<td><?php echo $data[1]; ?></td>
<td><?php echo $data[2]; ?></td>
<td><?php echo $data[3]; ?></td>
<td><?php echo $data[4]; ?></td>
<td><?php echo $data[5]; ?></td>
<td><?php echo $data[6]; ?></td>
<td><?php echo $data[7]; ?></td>
<td><?php echo $data[8]; ?></td>
<td><?php echo $data[9]; ?></td>
<td><?php echo $data[10]; ?></td>
<td><?php echo $data[11]; ?></td>
<td><?php echo $data[12]; ?></td>
<td><?php echo $data[13]; ?></td>
<td><?php echo $data[14]; ?></td>
<td><?php echo $data[15]; ?></td>
<td><?php echo $data[16]; ?></td>
<td><?php echo $data[17]; ?></td>
<?php
?>
</tr>
<?php
}
fclose($handle);
}
}
?>
</tbody>
</table>
</form>
</div>
<?php
// On enregistre chaque ligne dans un array
/* $lignes[] = array(colonne1,colonne2,colonne3,colonne4,colonne5,colonne6,colonne7,colonne8,colonne9,colonne10,colonne11,colonne12,colonne13,colonne14,colonne15,colonne16,colonne17,colonne18);*/
?>
<!-- <form method="POST">
<button type="input">Modifier</button>
<?php
/* if(isset($_POST['valider']))
{
// Paramétrage de l'écriture du futur fichier CSV
$chemin = $_POST['fileName'] . ".csv";
$delimiteur = ';';
// Création du fichier csv (le fichier est vide pour le moment)
$fichier_csv = fopen("fichiers/".$chemin, 'w+');
// corrige les problèmes d'affichage des caractères internationaux (les accents par exemple)
fprintf($fichier_csv, chr(0xEF).chr(0xBB).chr(0xBF));
// Boucle foreach sur chaque ligne du tableau
foreach($lignes as $ligne){
// chaque ligne en cours de lecture est insérée dans le fichier
// les valeurs présentes dans chaque ligne seront séparées par $delimiteur
fputcsv($fichier_csv, $ligne, $delimiteur);
}
// fermeture du fichier csv
fclose($fichier_csv); |
Partager