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
|
//Suppression des données présentes dans la table :
$effacement = "TRUNCATE TABLE $forfaits ";
mysql_query($effacement) or die("erreur supression données :" .mysql_error() );
//Récupération données importées :
$liste = $_POST['liste'];
if ($liste ==""){
echo '<br>';
echo '<td>Vous n\'avez pas rempli la liste, veuillez recommencer S.V.P.</a>';
echo '<br>';
echo '<td><a href="import_forfaits.php">Retour</a></td>';
exit;
}
$replace = str_replace("\n", ";", $liste);
$liste_forfaits = explode(";" , $replace);
$x= 0;
$c = count($liste_forfaits);
$a = $c/4;
$b = number_format($a, 0);
$y = $b*4;
while ($x < $y){
$id = trim($liste_forfaits[$x+0]);
$forfait = trim($liste_forfaits[$x+1]);
$code_forfait = trim($liste_forfaits[$x+2]);
$prix_forfait = trim($liste_forfaits[$x+3]);
$x=$x+4;
$requete = "INSERT INTO $forfaits SET id='$id', forfait='$forfait', code_forfait='$code_forfait', prix_forfait='$prix_forfait' ";
mysql_query($requete) or die("erreur :" .mysql_error() );
} |
Partager