<?php

// edit with personal settings
$location = '127.0.0.1';
$username = 'root';
$password = 'password';
$database = 'project_heatmap';

// connect to database
mysql_connect($location, $username, $password)
	or die("Error connecting to mysql: " . mysql_error());
mysql_select_db($database)
	or die("Error connecting to database: " . mysql_error());



foreach($filelist as $file) {

$table = "gheat_meting";

	if (($handle = fopen("wleiden.csv", "r")) !== FALSE) {
		while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) {
			$lat=str_replace("N ", "", $data[0]);
			$lon=str_replace("E ", "", $data[1]);
			$ssid=str_replace("'", "", $data[2]);
			$enc = substr($data[8], -2, 1);
			$query=mysql_query("INSERT INTO ".$table." (lat, long) VALUES ('$lat','$lon')");
			if (!$query) {
				die('Invalid query: ' . mysql_error());
			}
		}
		fclose($handle);
	}

}

?>
