Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require "PHPExcel/IOFactory.php";
- $servername = "localhost";
- $username = "root";
- $password = "1234";
- $dbname = "msanson";
- if(isset($_POST["upload"])){
- $inputfilename = $_FILES["file"]["tmp_name"];
- $exceldata = array();
- $conn = mysqli_connect($servername,$username,$password,$dbname);
- if(!$conn){
- die("Baglantı yapılamadı:". mysqli_connect_error());
- }
- try{
- $inputfiletype = PHPExcel_IOFactory::identify($inputfilename);
- $objReader = PHPExcel_IOFactory::createReader($inputfiletype);
- $objPHPExcel = $objReader->load($inputfilename);
- }catch(Exception $e){
- die('Yükleme hatası "'.pathinfo($inputfilename,PATHINFO_BASNAME).'":'.$e->getMassage());
- }
- $sheet = $objPHPExcel->getSheet(0);
- $highestRow = $sheet->getHighestRow();
- $highestColumn = $sheet->getHighestColumn();
- for($row = 1; $row <= $highestRow; $row++){
- $rowData = $sheet->rangeToArray('A'.$row.':'.$highestColumn.$row, NULL,TRUE,FALSE);
- $sql = "INSERT INTO msanlar
- il = ".$rowData[0][0].",
- Santral = ".$rowData[0][1].",
- MsanID = ".$rowData[0][4].",
- MsanAD = ".$rowData[0][9].",
- SignallingIP = ".$rowData[0][11].",
- RTPIP = ".$rowData[0][10].",
- OAMIP = ".$rowData[0][12].",
- Firma = ".$rowData[0][2].",
- MsanTipi = ".$rowData[0][3].",
- SWITCH =".$rowData[0][7].",
- node = ".$rowData[0][8].",
- DSLAMIP = ".$rowData[0][5].",
- DSLAMADI = ".$rowData[0][6].",
- MsanAdres = ".$rowData[0][13];
- if(mysqli_query($conn,$sql)){
- $exceldata[] = $rowData[0];
- }else{
- echo "Hata : ".$sql."<br>".mysqli_error($conn);
- }
- }
- mysqli_close($conn);
- }
- ?>
- <form action="" method="POST" enctype="multipart/form-data">
- <input type="file" name="file">
- <input type="submit" name="upload" value="Upload">
- </form>
Add Comment
Please, Sign In to add comment