0) { mysql_query("DELETE FROM calls WHERE OPERATOR = '".$_POST["voor"]."' "); include 'adif_parser.php'; $p = new ADIF_Parser; $p->feed($content); $p->initialize(); while($record = $p->get_record()) { if(count($record) == 0) { break; } $velden = implode("`,`",$importcols); $sql = "INSERT INTO calls (`".$velden."`)"; $sql .= " VALUES ("; for($v=0;$v 0) { mysql_query("DELETE FROM calls WHERE N3FJP_INITIALS = '".$_POST["voor"]."' "); $velden_array = array(); $lines = new CsvReader($_FILES['importfile']['tmp_name']); foreach ($lines as $line_number => $values) { $i=0; foreach ($values as $value) { if ($line_number == 0) { if(in_array($value, $importcols)) { $velden .= "`".$value."`,"; $velden_array[$i] = $value; $importrows[] = $i; } } else { if(in_array($i,$importrows)) { if($currentid < 1) { mysql_query("insert into calls values ();"); $currentid = mysql_insert_id(); } $sql = "UPDATE calls SET `".$velden_array[$i]."` = '".mysql_real_escape_string($value)."' WHERE id = ".$currentid; mysql_query($sql); } } $i++; } $currentid = -1; } echo "Klaar met importeren"; } else { echo "Geen data ontvangen!"; } } if(isset($waarden)) { $sql = "INSERT INTO calls (".substr($velden, 0, -1).") VALUES (".substr($waarden, 0, -1).");"; echo $sql."
"; mysql_query($sql) or die ($sql.mysql_error()); $waarden = ""; } $content = file_get_contents($_FILES["importfile"]["tmp_name"]); if(strlen($content) > 0) { $file = fopen($_FILES["importfile"]["tmp_name"],"r"); $i = 0; mysql_query("DELETE FROM calls WHERE OPERATOR = '".$_POST["voor"]."' "); while ($data = fgetcsv($file, 0, ",")) { if($i==0) { $ref = array_flip($data); } if($i > 0) { print_r($data); $velden = implode("`,`",$importcols); $sql = "INSERT INTO calls (`".$velden."`)"; $sql .= " VALUES ("; for($v=0;$v"; mysql_query($sql); } $i++; } echo "Klaar met importeren"; } else { echo "Geen data ontvangen!"; } */ ?>



CSV importeren