This topic is locked

Import Export Question

9/26/2018 9:58:07 PM
PHPRunner General questions
K
kegler author
  1. Import requires column header or else have to re-select the columns header one by one during import

    Is there any way to just import the 100 fields in sequential ? instead of recognizing the header column ?
  2. Export

    I need to export csv with header and footer record

    Which file should i edit to customise output?
  3. Anyone has experience with adding button for fputcsv ? To achieve desire output?

K
KevinMillican 9/28/2018


  1. Import requires column header or else have to re-select the columns header one by one during import

    Is there any way to just import the 100 fields in sequential ? instead of recognizing the header column ?
  2. Export

    I need to export csv with header and footer record

    Which file should i edit to customise output?
  3. Anyone has experience with adding button for fputcsv ? To achieve desire output?


  1. my Excel.XLSX imports automatically match the first row field names with the table field names - not sure why you're not seeing this.

K
kegler author 9/30/2018



  1. my Excel.XLSX imports automatically match the first row field names with the table field names - not sure why you're not seeing this.


Im trying to import data into DB by the columns not by the column names, my first row has no column name

admin 10/2/2018

PHPRunner has an option to import files without column headers but you will still need to match them manually with database columns.
If you are looking for something completely automated then you cannot use an export page. I would probably modify one of Add pages to allow you select and upload file and you can do your processing in event like BeforeAdd or CustomAdd.

K
kegler author 10/8/2018



PHPRunner has an option to import files without column headers but you will still need to match them manually with database columns.
If you are looking for something completely automated then you cannot use an export page. I would probably modify one of Add pages to allow you select and upload file and you can do your processing in event like BeforeAdd or CustomAdd.


Hi
Would you be able to guide me?

Which php file should I be looking at to modify the output? Any plugin used?
Actually I'm trying fgetcsv and fputcsv but I'm trying to figure how do I submit the add page to this php I created

admin 10/8/2018

I already explained what to do, you need to create a page that will accept file and your code needs to be placed into event.
You do not need to modify any files manually. You should not use any standalone PHP files. All PHP code goes into event.

K
kegler author 10/9/2018

Heres what I done

  1. Add page with file upload box
  2. Added this to event "after record added"


    // path where your CSV file is located

    define('CSV_PATH','C:\xampp\htdocs\fileconverter');

    // Name of your CSV file

    $csv_file = CSV_PATH . "\customerfile.csv";
    if (($handle = fopen($csv_file, "r")) !== FALSE) {

    fgetcsv($handle);

    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {

    $num = count($data);

    for ($c=0; $c < $num; $c++) {

    $col[$c] = $data[$c];
    }

    $col1 = $col[0];

    $col2 = $col[1];

    $col3 = $col[2];

    $col4 = $col[3];

    $col5 = $col[4];

    $query = "INSERT INTO CustomerFile(CustomerName, CustomerAddress, CustomerBankName, CustomerBankAccountNo, InvoiceDetails,) VALUES ('".$col1."','".$col2."','".$col3."','".$col4."','".$col5."')";

    $params = array();

    $options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );

    $stmt = sqlsrv_query($conn, $query, $params, $options );

    echo $stmt ;

    }

    fclose($handle);

    }

    echo "File data successfully imported to database!!";


and I got this error



Fatal error**89**[sub][/sub][sup][/sup]


Could it be my syntax error or ???
Please help

Thanks

admin 10/9/2018

Functions like sqlsrv_query() may not be available on your web server, based on what extension are available in php.ini. Use Database API instead:

https://xlinesoft.com/phprunner/docs/about_database_api.htm