|
 |
|
สอบถามเกี่ยวกับการ import excel to mysql หน่อยครับ |
|
 |
|
|
 |
 |
|
คือติดปัญหาตรงที่เวลาทำการอัพโหลดตัว excel เข้าไป ไฟล์ excel มันจะมี ชื่อ ของเเต่ละเเถว เช่น First Name , Last Name ซึ่งเป็นเเถวบนสุด มันอัพเข้าไปอยู่ใน database ด้วยคับ ต้องเขียนอย่างไรเพื่อไม่ให้มันอัพโหลดตัว header เข้าไปด้วย รบกวนด้วยครับ
Code (PHP)
$uploadfile = $_FILES['uploadfile']['tmp_name'];
require 'PHPExcel/Classes/PHPExcel.php';
require_once 'PHPExcel/Classes/PHPExcel/IOFactory.php';
$objExcel = PHPExcel_IOFactory::load($uploadfile);
foreach ($objExcel->getWorksheetIterator() as $worksheet) {
$highestrow = $worksheet->getHighestRow();
for ($row = 0; $row <= $highestrow; $row++) {
$name = $worksheet->getCellByColumnAndRow(0, $row)->getValue();
$email = $worksheet->getCellByColumnAndRow(1, $row)->getValue();
if ($email != '') {
$insertqry = "INSERT INTO `user`( `first_name`, `last_name`) VALUES ('$name','$email')";
$insertres = mysqli_query($con, $insertqry);
}
}
}
header('Location: index.php');

Tag : PHP, HTML5, JavaScript, Ajax, jQuery

|
|
 |
 |
 |
 |
Date :
2020-07-02 12:24:00 |
By :
worapong39 |
View :
696 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
for ($row = 1;...
|
 |
 |
 |
 |
Date :
2020-07-02 12:46:51 |
By :
PhrayaDev |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|