|
![](/images/resource/spacer.gif) |
|
สอบถามเกี่ยวกับการ import excel to mysql หน่อยครับ |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
คือติดปัญหาตรงที่เวลาทำการอัพโหลดตัว 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');
![s s](https://www.thaicreate.com/upload/stock/20200702122325.png?v=1001)
Tag : PHP, HTML5, JavaScript, Ajax, jQuery
![](/images/adv.jpg?v=1001)
|
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2020-07-02 12:24:00 |
By :
worapong39 |
View :
584 |
Reply :
2 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
Code (PHP)
for ($row = 1;...
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2020-07-02 12:46:51 |
By :
PhrayaDev |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 02
|