Bonjour,

J'aurais besoin d'un peu d'aide, je m'embrouille

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<?php
ini_set("memory_limit", "12000M"); // augmentation memoire
include("../includes/database_site.php");
 
$query_monde=$_GET['monde'];
$select = "SELECT numero, name FROM infos WHERE name='$query_monde'";
$result = mysql_query($select,$link_stats) or die ('Erreur : '.mysql_error() );
$total = mysql_num_rows($result);
 
if($total) {
    while($row = mysql_fetch_array($result)) {
$monde=$row["name"];
$numero_monde=$row["numero"];
    }
 
}
mysql_free_result($result);
 
$nom_url_fichiers = array(  
					array(  'Index' => "fichier1", 
							'table' => "$monde_players",
							'columns' => "(id, name, alliance_id, points, rank, towns) VALUES('$id', '$name', '$alliance_id', '$points', '$rank', '$towns')",
							'file_name' => "../mondes/$query_monde/data/players.txt", 
                                                        'list' => "$id, $name, $alliance_id, $points, $rank, $towns" 
 
					),
					);
 
 
foreach( $nom_url_fichiers as $fichiers ) {	
		echo $table = $fichiers['table'];
		$columns = $fichiers['columns'];
		$file_name = $fichiers['file_name'];
		$datafile = file("../mondes/$query_monde/data/players.txt");
                $list = $fichiers['list'];
 
foreach($datafile as $datum){
		$req = mysql_query("TRUNCATE TABLE $table");
		list($list) = explode(',', $datum);
		$sql = "INSERT INTO $table $columns";
		mysql_query($sql,$link_stats) or die("La table $table n'a pas été mise à jour ! </br>".mysql_error());
 
 
}echo "La table $table a été mise à jour !";
}
?>
Comment faire pour faire marcher les 2 foreach ? Merci d'avance !

ps : (la fonction LOAD DATA LOCAL INFILE ou LOAD DATA INFILE) ne marche pas sur mon serveur