Exemplo n.º 1
0
 function import_excel()
 {
     if ($_FILES['fileExcel']['tmp_name']) {
         $this->_db =& JFactory::getDBO();
         $dom = DOMDocument::load($_FILES['fileExcel']['tmp_name']);
         $rows = $dom->getElementsByTagName('Row');
         $first_row = 0;
         foreach ($rows as $row) {
             if ($first_row > 0) {
                 $id = "";
                 $name = "";
                 $price = "";
                 $index = 1;
                 $cells = $row->getElementsByTagName('Cell');
                 foreach ($cells as $cell) {
                     $key = "";
                     if ($index == 1) {
                         $key = 'id';
                     }
                     if ($index == 2) {
                         $key = 'name';
                     }
                     if ($index == 3) {
                         $key = 'price';
                     }
                     ${$key} = $cell->nodeValue;
                     $index += 1;
                 }
                 $id = intval($id);
                 $price = doubleval($price);
                 if ($id && $price) {
                     $query = "update  #__pr_product set price = {$price} where id= {$id}";
                     $this->_db->setQuery($query);
                     $this->_db->query();
                 }
             }
             $first_row++;
         }
         die("Đã cap nhat  thành công  gia cua " . ($first_row - 1) . "san pham");
     } else {
         parent::display();
     }
 }
Exemplo n.º 2
0
 function display()
 {
     parent::display();
 }