Hey all,
I have a script that uploads a selected csv file by the user and then changes the database and all that. I was wondering if it is possible to actually hardcode the location of the csv file into the script and then just run the code when page loads, and it udates the table.
This code below is the start of the script, so you can see on submit by the user it uploads it. But just wanted to hardcode the location of the csv file instead and have the script run on page load.
Any ideas?
//Verify uploaded file is a CSV
if ($_POST["submit"]=="submit") {
//Sets uploaded file a temporary name
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
//Sets temp name to variable
$file=$_FILES['userfile']['tmp_name'];
//Connect to database
$linkdata = mysql_connect($hostname_localhost, $username_localhost, $password_localhost) or die('Could not connect: ' . mysql_error());
mysql_select_db($database_localhost) or die('Could not select database');
//Post $file variable to getcsv function and set $dump to $CSVarray
$CSVarray = getcsv($file);
//Post $CSVarray and table name to makeINSERTS function
$CSVarray = makeINSERTS($CSVarray, "$tbl");
//Connect to database and remove field headings
mysql_select_db($database_localhost, $localhost);
$query_remove_headings = "DELETE FROM ".$tbl." WHERE `RECORDID` = '' AND `ID` = 'ID' AND `COMPANY_NAME` = 'COMPANY_NAME' AND `CUSTOMER_NAME` = 'CUSTOMER_NAME' LIMIT 1";
$headings = mysql_query($query_remove_headings, $localhost) or die(mysql_error());
Thanks for your response.