Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-Type: text/plain');
- $Filepath = "./test.xlsx";
- require('SpreadsheetReader.php');
- $user = 'root';
- $pass = '';
- $dbh = new PDO('mysql:host=localhost;dbname=results', $user, $pass);
- $sql = "DELETE FROM t_results WHERE id";
- $dbh->exec($sql);
- try
- {
- $Spreadsheet = new SpreadsheetReader($Filepath);
- $Sheets = $Spreadsheet -> Sheets();
- foreach ($Sheets as $Index => $Name)
- {
- $Spreadsheet -> ChangeSheet($Index);
- foreach ($Spreadsheet as $Key => $Row)
- {
- if ($Row)
- {
- if($dbh){
- $sql = "INSERT INTO t_results (id, name, class, score)
- VALUES ('$Row[0]', '$Row[1]', '$Row[2]', '$Row[3]')";
- $dbh->exec($sql);
- echo $Row[3];
- }
- }
- else
- {
- var_dump($Row);
- }
- }
- }
- }
- catch (Exception $E)
- {
- echo $E -> getMessage();
- }
- ?>
Add Comment
Please, Sign In to add comment