Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
$fileName = $_POST['name'];
$info = pathinfo($_FILES['fileInput']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = $fileName.".".$ext;
$target = 'excelfiles/'.$newname;
move_uploaded_file( $_FILES['fileInput']['tmp_name'], $target);
include 'excel_reader/excel_reader.php'; // include the class
// creates an object instance of the class, and read the excel file data
$excel = new PhpExcelReader;
$excel->read($target);
function sheetTitle($sheet)
{
// create the table and fill the column names.
$fileName = $_POST['name'];
$y = 1;
$strsql = "CREATE TABLE `".$fileName."` (id int(10) NOT NULL AUTO_INCREMENT";
while($y <= $sheet['numCols'])
{
$x = 1;
$cell = $sheet["cells"][$x][$y];
$re .= $cell;
$data = array($cell);
$x++;
$strsql .= ", `".$data[0]."` VARCHAR(1000)";
$y++;
}
$strsql .= ', KEY(id))';
$resultTable = mysql_query($strsql);
$y = 1;
$strsql = "CREATE TABLE `".$fileName."` (id int(10) NOT NULL AUTO_INCREMENT";
$strsql2 = "CREATE TRIGGER upd_check AFTER UPDATE ON ".$fileName." FOR EACH ROW";
while($y <= $sheet['numCols'])
{
$x = 1;
$cell = $sheet["cells"][$x][$y];
$re .= $cell;
$strsql2 .= " IF NEW.".$re." <> OLD.".$re." THEN INSERT INTO ".$fileName."_logs (oudeWaarde, nieuweWaarde) VALUES (OLD.".$re.", NEW.".$re.") END IF";
$resultTrigger = mysql_query($strsql2);
if($resultTrigger == FALSE)
{
die('Error: '. mysql_error());
}
$data = array($cell);
$x++;
$strsql .= ", `".$data[0]."` VARCHAR(1000)";
$y++;
}
$strsql .= ', KEY(id))';
$resultTable = mysql_query($strsql);
$fileName = $_POST['name'];
$name = get_current_user();
$strsqlLog = "CREATE TABLE `".$fileName."_logs` (id int(10) NOT NULL AUTO_INCREMENT, username VARCHAR(1000), oudeWaarde VARCHAR(1000), nieuweWaarde VARCHAR(1000), datumTijd VARCHAR(1000), KEY(id))";
$resultLogTable = mysql_query($strsqlLog);
$date = date('YmdHis');
$y = 1;
$strsql = "CREATE TABLE `".$fileName."` (id int(10) NOT NULL AUTO_INCREMENT";
$strsql2 = "CREATE TRIGGER upd_check AFTER UPDATE ON ".$fileName." FOR EACH ROW";
while($y <= $sheet['numCols'])
{
$x = 1;
$cell = $sheet["cells"][$x][$y];
$re .= $cell;
$strsql2 .= " IF NEW.".$cell." <> OLD.".$cell." THEN INSERT INTO ".$fileName."_logs (oudeWaarde, nieuweWaarde) VALUES (OLD.".$cell.", NEW.".$cell.") END IF";
$data = array($cell);
$x++;
$strsql .= ", `".$data[0]."` VARCHAR(1000)";
$y++;
}
$strsql .= ', KEY(id))';
$resultTable = mysql_query($strsql);
$resultTrigger = mysql_query($strsql2);
$fileName = $_POST['name'];
$name = get_current_user();
$strsqlLog = "CREATE TABLE `".$fileName."_logs` (id int(10) NOT NULL AUTO_INCREMENT, username VARCHAR(1000), oudeWaarde VARCHAR(1000), nieuweWaarde VARCHAR(1000), datumTijd VARCHAR(1000), KEY(id))";
$resultLogTable = mysql_query($strsqlLog);
$date = date('YmdHis');
$y = 1;
$strsql = "CREATE TABLE `".$fileName."` (id int(10) NOT NULL AUTO_INCREMENT";
$strsql2 = "CREATE TRIGGER upd_check AFTER UPDATE ON ".$fileName." FOR EACH ROW";
while($y <= $sheet['numCols'])
{
$x = 1;
$cell = $sheet["cells"][$x][$y];
$re .= $cell;
$strsql2 .= " IF NEW.".$cell." <> OLD.".$cell." THEN INSERT INTO ".$fileName."_logs (oudeWaarde, nieuweWaarde) VALUES (OLD.".$cell.", NEW.".$cell.") END IF";
$data = array($cell);
$x++;
$strsql .= ", `".$data[0]."` VARCHAR(1000)";
$y++;
}
$strsql .= ', KEY(id))';
$resultTable = mysql_query($strsql);
print_r($strsql2);
$strsql2 = "DELIMETER GO CREATE TRIGGER upd_check AFTER UPDATE ON ".$fileName." FOR EACH ROW BEGIN";
$strsql2 .= " IF NEW.".$cell." <> OLD.".$cell." THEN INSERT INTO ".$fileName."_logs (oudeWaarde, nieuweWaarde) VALUES (OLD.".$cell.", NEW.".$cell."); END IF; END; GO";
$strsql2 = "DELIMITER GO CREATE TRIGGER upd_check AFTER UPDATE ON ". $fileName ." FOR EACH ROW BEGIN";
while($y <= $sheet['numCols'])
{
$x = 1;
$cell = $sheet["cells"][$x][$y];
$re .= $cell;
$strsql2 .= " IF NEW.".$cell." <> OLD.".$cell." THEN INSERT INTO ".$fileName."_logs (oudeWaarde, nieuweWaarde) VALUES (OLD.".$cell.", NEW.".$cell.") END IF;";
$data = array($cell);
$x++;
$strsql .= ", `".$data[0]."` VARCHAR(1000)";
$y++;
}
$strsql2 .= "END; GO";
$y = 1;
$strsql = "CREATE TABLE `".$fileName."` (id int(10) NOT NULL AUTO_INCREMENT";
$strsql2 = "DELIMITER GO CREATE TRIGGER upd_check AFTER UPDATE ON ". $fileName ." FOR EACH ROW BEGIN";
while($y <= $sheet['numCols'])
{
$x = 1;
$cell = $sheet["cells"][$x][$y];
$re .= $cell;
$strsql2 .= " IF NEW.".$cell." <> OLD.".$cell." THEN INSERT INTO ".$fileName."_logs (oudeWaarde, nieuweWaarde) VALUES (OLD.".$cell.", NEW.".$cell.") END IF;";
$data = array($cell);
$x++;
$strsql .= ", `".$data[0]."` VARCHAR(1000)";
$y++;
}
$strsql2 .= "END; GO";
$strsql .= ', KEY(id))';
$resultTable = mysql_query($strsql);
$resultTrigger = mysql_query($strsql2);
if($resultTrigger == FALSE)
{
die('Error: '. mysql_error());
}
$strsql2 = "DELIMITER GO". PHP_EOL . PHP_EOL ."CREATE TRIGGER upd_check AFTER UPDATE ON ". $fileName . PHP_EOL ." FOR EACH ROW ". PHP_EOL ."BEGIN". PHP_EOL;
while($y <= $sheet['numCols'])
{
$x = 1;
$cell = $sheet["cells"][$x][$y];
$re .= $cell;
$strsql2 .= "IF NEW.".$cell." <> OLD.".$cell." THEN". PHP_EOL ."INSERT INTO ".$fileName."_logs (oudeWaarde, nieuweWaarde) VALUES (OLD.".$cell.", NEW.".$cell."); ". PHP_EOL ."END IF;". PHP_EOL;
$data = array($cell);
$x++;
$strsql .= ", `".$data[0]."` VARCHAR(1000)";
$y++;
}
$strsql2 .= "END;". PHP_EOL ."GO";
echo $strsql2;
We gebruiken essentiële cookies om deze site te laten werken, en optionele cookies om de ervaring te verbeteren.