Page 2 of 2

Re: Import csv file

Posted: Thu Jul 16, 2020 11:15 am
by kev1n
There are syntax errors in import.php (use https://phpcodechecker.com/ to check for errors).

I think it should be like this:

Code: Select all

<?php
//import.php
if (isset($_POST["customerName"])) {
    $connect = new PDO("mysql:host=localhost;dbname=nubuilder4", "root", "");
    $customerName = $_POST["customerName"];
    $customerPhone = $_POST["customerPhone"];
    $customerEmail = $_POST["customerEmail"];
    $customerAddress = $_POST["customerAddress"];
    $appointmentDate = $_POST["appointmentDate"];

    for ($count = 0;$count < count($customerName);$count++) {
        $query .= "
  INSERT INTO tbl_Customers(customerName, customerPhone, customerEmail, customerAddress, appointmentDate)
  VALUES ('" . $customerName[$count] . "', '" . $customerPhone[$count] . "', '" . $ccustomerEmail[$count] . "', '" . $customerAddress[$count] . "', '" . $appointmentDate[$count] . "');

  ";
    }
    $statement = $connect->prepare($query);
    $statement->execute();
}

?>

Re: Import csv file

Posted: Thu Jul 16, 2020 11:18 am
by hiramalik
You are a saviour..
Thank you sooooo much :) :D

Re: Import csv file

Posted: Fri Jul 17, 2020 1:04 pm
by hiramalik
Here again with another issue. Now that everything else works fine, file is being imported thrice. For example if I have imported 3 rows. Each row will be imported thrice making total of 9 rows. Please help..

Re: Import csv file

Posted: Sun Jul 19, 2020 10:46 am
by kev1n
Replace this line:

Code: Select all

 $(document).on('click', '#import_data', function(){
with this:

Code: Select all

 $(document).off('click', '#import_data').on('click', '#import_data', function(){

Re: Import csv file

Posted: Tue Jul 21, 2020 8:55 pm
by hiramalik
Thanks Kev1n :D

Re: Import csv file

Posted: Tue Oct 06, 2020 2:25 am
by admin
There is now a simple CSV Import/Export available in nuBuilder Forte.

https://forums.nubuilder.cloud/viewtopic.php?f=18&t=10583


Steven

Re: Import csv file

Posted: Wed Oct 14, 2020 7:42 am
by kev1n
Cool - it's a nice addition!

Re: Import csv file

Posted: Wed Oct 14, 2020 8:26 pm
by admin
Thanks.

I used some of your code.


Steven