Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Questions related to customising nuBuilder Forte with JavaScript or PHP.
kev1n
nuBuilder Team
Posts: 4581 Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 536 times
Contact:
Unread post
by kev1n » Thu Jul 16, 2020 11:15 am
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();
}
?>
hiramalik
Posts: 20 Joined: Wed Jul 15, 2020 12:34 pm
Unread post
by hiramalik » Thu Jul 16, 2020 11:18 am
You are a saviour..
Thank you sooooo much
hiramalik
Posts: 20 Joined: Wed Jul 15, 2020 12:34 pm
Unread post
by hiramalik » Fri Jul 17, 2020 1:04 pm
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..
kev1n
nuBuilder Team
Posts: 4581 Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 536 times
Contact:
Unread post
by kev1n » Sun Jul 19, 2020 10:46 am
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(){
kev1n
nuBuilder Team
Posts: 4581 Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 536 times
Contact:
Unread post
by kev1n » Wed Oct 14, 2020 7:42 am
Cool - it's a nice addition!
admin
Site Admin
Posts: 2829 Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times
Unread post
by admin » Wed Oct 14, 2020 8:26 pm
Thanks.
I used some of your code.
Steven