Cool - I have this so far and apart from the situ with the file it's cool.
$fileDir = "/monkey/sites/thebestbeer/downloads";
$fileUrl = "/downloads/";
if(isset ($fileUpload)) {
copy($fileUpload, "$fileDir/beerSpreadsheet.txt");
$sqlConnect = mysql_connect("localhost", "thebestbeer", "thecoolestbeer");
mysql_select_db("thebestbeer", $sqlConnect);
$query = "DROP TABLE bottled_beer";
mysql_query($query, $sqlConnect);
print "<p>Table 'bottled_beer' has been deleted...<br>";
$query = "CREATE TABLE bottled_beer ( id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
uniqueId VARCHAR(25),
breweryName VARCHAR(40),
beerName VARCHAR(40),
beerStyle VARCHAR(30),
description TEXT,
percentAlcohol VARCHAR(4),
wholesalePrice VARCHAR(6),
bottlePrice VARCHAR(6),
imageName VARCHAR(20),
countryOrigin VARCHAR(15),
bottleSize VARCHAR(5),
stockAvailability VARCHAR(35)
)";
mysql_query($query, $sqlConnect);
print "Table 'bottled_beer' has been re-created...<br>";
$beerDataFile = "../downloads/beerSpreadsheet.txt";
$file = file($beerDataFile);
$filePointer = fopen($beerDataFile, "a") or die("Datafile has failed to open.");
while (list($key, $val) = each ($file)) {
$data = explode("\t", $val);
$query = "INSERT INTO bottled_beer ( uniqueId, breweryName, beerName, beerStyle, description, percentAlcohol, wholesalePrice, bottlePrice, imageName, countryOrigin, bottleSize, stockAvailability ) VALUES ( '$data[0]', '$data[1]', '$data[2]', '$data[3]', '$data[4]', '$data[5]', '$data[6]', '$data[7]', '$data[8]', '$data[9]', '$data[10]', '$data[11]' )";
mysql_query($query, $sqlConnect) or die("Actually it's here: ".mysql_error());
$beerDetails = "".$data[1]."|".$data[2]."|".$data[3]."|".$data[10]."|".$data[5]."|".$data[7]."|http://www.thebestbeer.co.uk/php-bin/beerDetails.php?uniqueId=".$data[0]."&beerName=".$data[2]."";
flock($filePointer, 1);
fputs($filePointer, "$beerDetails\n");
flock($filePointer, 3);
}
print "<p>The table bottled_beers has been <b>successfully</b> populated.";
fclose($filePointer);
Where in this would that be best put?