Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Is it possible to import data into a subform from a file?

Questions related to customising nuBuilder Forte with JavaScript or PHP.
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Is it possible to import data into a subform from a file

Unread post by kknm »

Janusz wrote:the current form Primary key can be easilly sent from JS to PHP and used in mysql
so you collect data from excel; adding the current record Primary key, inserting data to table and thats all

Code: Select all

//get id of the current main record (JS)
var id=nuGetProperty('record_id');

// prepare to be available in php (JS)
nuSetProperty('CON_PART_ID', id);

//recover and use in PHP (PHP)
$pid=('#CON_PART_ID#');
$uid=nuID();
$x="INSERT INTO connection (connection_id,con_part,con_rap) VALUES ('$uid','$pid','$rap_id')";
and for adding subform unique id use nuID(); (for more records - in the loop - every line - has to have new nuID generated)
I became interested, but in your code I do not find the file name to import and work with the file.What is important - to use php-funсtion should be an unprivileged user.
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Re: Is it possible to import data into a subform from a file

Unread post by Janusz »

i do not use in my application php data import from the file so do not have ready example to share - but normally within php it should be easy to read data from external files - depandind on data fromat etc.

just few examples:

https://phppot.com/php/import-excel-fil ... 0by%20row.

https://phpenthusiast.com/blog/parse-csv-with-php
If you like nuBuilder, please leave a review on SourceForge
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Is it possible to import data into a subform from a file

Unread post by kknm »

Janusz wrote:i do not use in my application php data import from the file so do not have ready example to share - but normally within php it should be easy to read data from external files - depandind on data fromat etc.
Thanks for the valuable advice. I had to be perverted, because I don’t have all the rights to the resources of a mixed (Linux-windows) local area network. I used php, smbclient, phpExcel to write directly to the mysql database according to your advice. Of course, this is unsafe, but it eliminates unforeseen errors from the database users.
Post Reply