create import file csv or excel to database

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.

create import file csv or excel to database

Postby creat015 » Fri Dec 29, 2017 4:24 am

Hello Sir

i want to ask, how to can import file csv or excel to database?

i try to search in this forum, that phpmaker does not have a feature to import to the database.

what can not be tricked sir?

eg create a csv import feature manually?

if you can how to make the import feature csv manually?

because the data I'm pretty much on, it's a long time to add them one by one

what can not be tricked sir?

eg create a csv import feature manually?

if you can how to make the import feature csv manual?

because the data I'm pretty much on, it's a long time to add them one by one

I've tried importing csv files directly into phpmyadmin, but error.

I confuse the error where, whether the friends in this forum have a csv template that I can use

sorry my english not good

thanks
creat015
 
Posts: 12
Joined: Sat Dec 23, 2017 1:39 am

Re: create import file csv or excel to database

Postby kirondedshem » Fri Dec 29, 2017 2:41 pm

What am currenly using is import from excel, I use a php library where I allow a user to upload an excel file then I use the library to read the excel file orw by row as i perform my desired import actions and validations.

Serach for "PHPExcel" at codeplex.com/PHPExcel. This library can read and write and create excel files and supports formatting, password locking etc. after downloading it you should see a bunch of examples that can help you out. You can then create a custom file which you submit your excel file to and it performs the import.
NOTE: just use its examples to find out how to use it but its basically something like below
for example assuming youe have downloaded and put library in folder called "PhpExcelmport", and you have a custom file which uploads and excel file and passes it as to this another custom file for processing, processing would be liek below

//require_once dirname(__FILE__) . '/../Classes/PHPExcel/IOFactory.php';
require_once dirname(__FILE__) . '/PhpExcelmport/PHPExcel/IOFactory.php';
//ASSUME upload field name is called excel_file
$objPHPExcel = PHPExcel_IOFactory::load($_FILES['excel_file']['tmp_name']);
//loop through all worksheets if many
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
$sheetName = $worksheet->getTitle();

foreach ($worksheet->getRowIterator($starting_row) as $row) {

//read values using column and row index for each row
//read value from frist column of this row
$month_year_value = $worksheet->getCellByColumnAndRow(0, $row->getRowIndex())->getFormattedValue();
//read value from second column of this row
$receipt_number_value = $worksheet->getCellByColumnAndRow(1, $row->getRowIndex())->getCalculatedValue();

}



}
kirondedshem
 
Posts: 331
Joined: Sat Jan 28, 2017 7:13 pm

Re: create import file csv or excel to database

Postby creat015 » Sun Jan 07, 2018 9:41 pm

sorry sir i still confused about your tutorial

"for example assuming you have downloaded and put library in folder called "PhpExcelmport"

library in folder what sir? in program files PHPMaker2018 >> and then create new folder "PhpExcelmport"

or put libarary in folder wamp >> www >> mydataphpmaker and then create new folder "PhpExcelmport"

or how do?

your code above is placed where sir?

thanks before
creat015
 
Posts: 12
Joined: Sat Dec 23, 2017 1:39 am

Re: create import file csv or excel to database

Postby kirondedshem » Sun Jan 07, 2018 10:01 pm

the code above belongs in a custom file, so just create a custom file and which has a form having upload field and the from submits to the same or another custom file.
Then place this code in the custom file that submits the excel file.

If you have done the above you should be able to atlaest use the code above to start progressing in your excel import. If its not workign for you then look at thier examples on how to read an excel file and you should be able to get it to work.

NOTE:PHPExcel is a php library, so take a look at the examples of how to use it (they should be in the same zip you downloaded). This means this library has nothing to do with phpmaker it is used as is, thats why I advise you to first be able to use it in any php file(without using phpmaker) correctly. Such that when you create a custom file you will just be copying the code from your manual php file into it
kirondedshem
 
Posts: 331
Joined: Sat Jan 28, 2017 7:13 pm

Re: create import file csv or excel to database

Postby creat015 » Sat Jan 13, 2018 1:02 pm

hello sir

sorry for late reply

I have succeeded create import files with csv

but there is another problem

table database imported csv file does not appear in phpmaker?

I check the table, appear error messages like this in box popup

"list index out of bounds (-1)"

the above error message appears only if I add a new table to import this csv file sir, if I delete the result table import csv the error message does not exist.

Please help.

thank you
creat015
 
Posts: 12
Joined: Sat Dec 23, 2017 1:39 am

Re: create import file csv or excel to database

Postby kirondedshem » Sat Jan 13, 2018 10:02 pm

>I have succeeded create import files with csv
I thought this means you have :
1:succeded in creating form where a user can locate an execl file and the submit
2. succeded in creating the logic to read the excel file on submission and loop through the row and columns as you insert each row into your desired tbale in the database.

If not then explain how far you have gone with the above as I feel these are were the error should be coming from

>table database imported csv file does not appear in phpmaker?
So I dont undertand why you still need to see the imported csv file in phpmaker, and what do you mean by seeing the csv file in phpmaker, I thought what you wanted was to see the data imported from the execl file on your exeisting list pages, so explain why you still need to see it and where you need to see it if possible explain what you have achived so far as well as how the user goes about using your import process.

>the above error message appears only if I add a new table to import this csv file sir, if I delete the result table import csv the error message does not exist.
What do you mean by adding atbale to import the csv.

NOTE:ALso paste your code so we can maybe try to find out were the error is comming from. Of course with an explanation and example data if possible.
kirondedshem
 
Posts: 331
Joined: Sat Jan 28, 2017 7:13 pm

Re: create import file csv or excel to database

Postby creat015 » Sun Jan 14, 2018 1:44 am

kirondedshem wrote:
> >I have succeeded create import files with csv
> I thought this means you have :
> 1:succeded in creating form where a user can locate an execl file and the submit
> 2. succeded in creating the logic to read the excel file on submission and loop
> through the row and columns as you insert each row into your desired tbale in the
> database.
>
> If not then explain how far you have gone with the above as I feel these are were the
> error should be coming from
>
> >table database imported csv file does not appear in phpmaker?
> So I dont undertand why you still need to see the imported csv file in phpmaker, and
> what do you mean by seeing the csv file in phpmaker, I thought what you wanted was to
> see the data imported from the execl file on your exeisting list pages, so explain
> why you still need to see it and where you need to see it if possible explain what
> you have achived so far as well as how the user goes about using your import process.
>
> >the above error message appears only if I add a new table to import this csv file
> sir, if I delete the result table import csv the error message does not exist.
> What do you mean by adding atbale to import the csv.
>
> NOTE:ALso paste your code so we can maybe try to find out were the error is comming
> from. Of course with an explanation and example data if possible.

thank you sir for your reply

sorry I forgot to tell the success I mean :

yes sir, I have successfully created a manual import file and successfully uploaded csv file to database sir

I follow the tutorial in here sir : (goo *dot gl *slash rmNZna) (change dot to . and slash to / for open the tutorial i follow)

I want to generate data imported csv file in phpmaker so can i edit again sir, example for city or province columns I will make to select or dropdown, and i want to display this data imported csv in phpmaker for easy editing more complete sir

i try to add new table for to accommodate data file import csv sir,

before when the new table does not exist, when I click the table in phpmaker there is no error, but a new error appears after I create a new table to accommodate data imported csv

error message that appears when I click the table in phpmaker like this:

"index list out of bounds (-1)"

this sir the screenshoot i mean, sorry name i blur

(goo *dot gl *slash uJeFzX) (change dot to . and slash to / for open the url)

sorry this forum can not add external url :(

please help me sir

thank you
creat015
 
Posts: 12
Joined: Sat Dec 23, 2017 1:39 am

Re: create import file csv or excel to database

Postby saleh » Sun Jan 14, 2018 3:17 am

Here is a file import method for Excel file
Include it as a packer

download file:
htxxs://www.alshref.com/up/do.php?id=117

Here is the explanation:
hxxs://www.youtube.com/watch?v=pL5WSNpUZWo
saleh
 
Posts: 132
Joined: Mon Dec 09, 2013 11:21 pm

Re: create import file csv or excel to database

Postby kirondedshem » Sun Jan 14, 2018 2:57 pm

SInce you said the actual csv import worked and the error is coming from you adding a new table to phpmaker then I think something went wrong with your project or its a bug in phpmaker 2018, coz Ive never seen it before so i cant really help you with that. I suggest you send this screen shot to support if you can.

But you can try to create a new project and then import the settings and customisations afresh just incase the current sooluion file is corrupted and see if it helps.
kirondedshem
 
Posts: 331
Joined: Sat Jan 28, 2017 7:13 pm

Re: create import file csv or excel to database

Postby creat015 » Mon Jan 15, 2018 12:53 pm

saleh wrote:
> Here is a file import method for Excel file
> Include it as a packer
>
> download file:
> htxxs://www.alshref.com/up/do.php?id=117
>
> Here is the explanation:
> hxxs://www.youtube.com/watch?v=pL5WSNpUZWo

thank you sir for your help

i try its works (i can import file xls to database)

thank you very much sir

kirondedshem wrote:
> SInce you said the actual csv import worked and the error is coming from you adding
> a new table to phpmaker then I think something went wrong with your project or its
> a bug in phpmaker 2018, coz Ive never seen it before so i cant really help you with
> that. I suggest you send this screen shot to support if you can.
>
> But you can try to create a new project and then import the settings and customisations
> afresh just incase the current sooluion file is corrupted and see if it helps.

thank you sir for your help

if you did not tell me to re-create the new project, maybe I still stuck in the error project1.

until now i still confuse the error in the project1 sir
I do not know where the error is where

earlier I try the same project1 setting with the project2 setting I check carefully, afraid there is a system that I accidentally checklist,
evidently the settings or system in project1 with project2 same sir.

means maybe this is a bug from phpmaker2018
maybe the future can be fixed this problem so as not to repeat this problem.

suggestions from me and my friends who are on this thread, if having the same problem as my problem, please try to create new project with same database, good luck.

once again thanks a lot of help.

new this time and in just in this forum the questions and answers provided really really help me as a new user of phpmaker

thanks again sir for help me
creat015
 
Posts: 12
Joined: Sat Dec 23, 2017 1:39 am


Return to General Discussion (PHPMaker)