Well I submit the excel file via form and like I said, the previous smaller excel file was actually processed.
Here is the form code:
<form name="form3" enctype="multipart/form-data" method="post" action="upload_file.php" target="_blank">
<label>
<input type="file" name="excel_file" id="excel_file">
</label>
<label>
<input type="submit" name="excel_submit" id="excel_submit" value="Submit">
</label>
</form>
Here is upload_file.php:
<?php
require_once("upload_excel.php");
if ($_FILES["excel_file"]["error"] > 0) {
echo "Return Code: " . $_FILES["excel_file"]["error"] . "<br />";
}
else {
echo "Upload: " . $_FILES["excel_file"]["name"] . "<br />";
echo "Type: " . $_FILES["excel_file"]["type"] . "<br />";
echo "Size: " . ($_FILES["excel_file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["excel_file"]["tmp_name"] . "<br />";
}
upload_excel($_FILES["excel_file"]["tmp_name"]);
?>
And here is upload_excel.php:
<?php
function upload_excel($file) {
require_once("Excel/excel_reader2.php");
$data = new Spreadsheet_Excel_Reader();
$data->read($file);
$serial_used = array();
$serial_active = array();
$count = 1;
while($data->val($count,'L') != '') {
if ($data->val($count,'L')=='Card is Active') {
array_push($serial_active, $data->val($count,'A'));
}
else
array_push($serial_used, $data->val($count,'A'));
$count++;
}
//print_r($serial_active);
//print_r($serial_used);
$con = mysql_connect("host","use","pass");
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('PepBase',$con);
foreach($serial_used as $serial_used2) {
mysql_query("UPDATE Vodacom
SET Status='used'
WHERE serialNR='$serial_used2'");
}
foreach($serial_active as $serial_active2) {
mysql_query("UPDATE Vodacom
SET Status='active'
WHERE serialNR='$serial_active2'");
}
mysql_close($con);
}
?>