Skip to main content

Posts

Showing posts from March, 2017

Import Excel XLSX ke dalam Database Mysqli

Langkah kerja 1. Download dan Letakkan dalam folder htdocs 2. Buat file excel.xlsx dengan struktur tersebut, pada folder yang sama 3. Buat database dan tabel dalam mysql dengan struktur tersebut pula. Kode <!DOCTYPE html> <html> <head>   <title>Progress Bar</title> </head> <body> <!-- Progress bar holder --> <div id="progress" style="width:500px;border:1px solid #ccc;"></div> <!-- Progress information --> <div id="information" style="width"></div> <?php /**  * PHPExcel - Excel data import to MySQL database script example  * ==============================================================================  *  * @version v1.0: PHPExcel_excel_to_mysql_demo.php 2016/03/03  * @copyright Copyright (c) 2016, http://www.ilovephp.net  * @author Sagar Deshmukh <sagarsdeshmukh91@gmail.com>  * @SourceOfPHPExcel https://github.com/PHPOffice/PHPExcel, https://sourceforg

Menginput hasil tampilan tabel ke database

<?php $dom = new DOMDocument(); //load the html $html = $dom->loadHTMLFile("coba_dom.html");   //discard white space   $dom->preserveWhiteSpace = false;     //the table by its tag name $tables = $dom->getElementsByTagName('table');       //get all rows from the table $rows = $tables->item(0)->getElementsByTagName('tr');     // get each column by tag name $cols = $rows->item(0)->getElementsByTagName('th');   $row_headers = NULL; foreach ($cols as $node) {     //print $node->nodeValue."\n";       $row_headers[] = $node->nodeValue; }   $table = array();   //get all rows from the table $rows = $tables->item(0)->getElementsByTagName('tr');   foreach ($rows as $row)   {      // get each column by tag name       $cols = $row->getElementsByTagName('td');       $row = array();     $i=0;     foreach ($cols as $node) {         # code...         //print $node->