include "config.php";
$importcols = array("BAND","CALL","COMMENT","CONT","COUNTRY","CQZ","DXCC","FREQ","GRIDSQUARE","N3FJP_COMPUTERNAME","N3FJP_INITIALS","N3FJP_MODECONTEST","N3FJP_SPCNUM","N3FJP_STATIONID","NAME","OPERATOR","PFX","QSO_DATE","RST_RCVD","RST_SENT","STATE","TIME_OFF","TIME_ON");
?>
Je moeder
require_once('csv.php');
if(in_array($_POST['voor'],$operators))
{
$content = file_get_contents($_FILES["importfile"]["tmp_name"]);
if(strlen($content) > 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!";
}
*/
?>