All pastes #771094 Raw Edit

Mine

public text v1 · immutable
·published 2007-11-12 20:08 UTC
rendered paste body
<?php
/**/


mysql_select_db("companies", $connection) or die('error connecting');

require('http://www.viametric.net/companies/import.php');
/*
Note: this program is written so that the output file will have the header information from
the first data file: blogdatafile.csv.  This can obviously be rewritten, but it was coded as such
in order to achieve output matching that which was previously specified.

Step one: read files
step two: extract header/data
step three: create Tables-- create master table is external function
step four: import data
step five: manipulate data
step six: add data to master table
step seven: output header-- external function
step eight: output data
*/

if ($_FILES["blog"]["error"] > 0):
	echo "Error: " . $_FILES["blog"]["error"] . "<br />";
endif;
if ($_FILES["web"]["error"] > 0):
	echo "Error: " . $_FILES["web"]["error"] . "<br />";
endif;
if ($_FILES["blog"]["error"] == 0 && $_FILES["web"]["error"] == 0):

	move_uploaded_file($_FILES["blog"]["tmp_name"], $_FILES["blog"]["name"]);
	move_uploaded_file($_FILES["web"]["tmp_name"], $_FILES["web"]["name"]);

	$blog = new CSV($_FILES["blog"]["name"], "blog");
		
	$web = new CSV($_FILES["web"]["name"], "web");

	$blog->createMasterTable();
	$blog->processData();
	$web->processData();
	$blog->insertToMasterTable();
	$web->insertToMasterTable();
	$blog->sortRecordsAndOutputToFile();
	header('Content-type: text/csv');
	header('Content-Disposition: attachment; filename="output.csv"');
	readfile('output.csv');
endif;

?>