Welcome, Guest!!

Date: Sat, Apr 5th 2025
Time:

  Login Join GTK
 
 

Inserting multiple records into database with PHP and MySQL

Topic Started By: goddy       Created: Nov 18th, 2017, 7:48 am

  •     (Page 1 of 1)     Comments (0)    

There are many ways you can do this and few examples are given below:

Inserting multiple records into database example one:

 

$sqlAdd = "INSERT INTO contacts (firstname, lastname, email)

VALUES ('Godwin', 'Asu', 'asu@example.com');";

$sqlAdd .= "INSERT INTO contacts (firstname, lastname, email)

VALUES ('Mary', 'Ene', 'mary@example.com');";

$sqlAdd .= "INSERT INTO contacts (firstname, lastname, email)

VALUES ('Emeka', 'Ogbonna', 'emeka@example.com')";



if (mysqli_multi_query($conn, $sql)) {

    echo "Records added successfully";

} else {

    echo "Error add records: " . $sql . "

" . mysqli_error($conn);

}

 

Inserting multiple records into database example two:

INSERT INTO contacts (firstname, lastname, email)
values('$firstname', '$lastname', '$email')
,('$firstname', '$lastname', '$email')
,('$firstname', '$lastname', '$email')

Need more examples or clarifications, drop your comments below.

 


×

Subscribe to get notifications when I create new topics by clicking the SUBSCRIBE button at the top of this page if you have not already subscribed. Thanks.




  •     (Page 1 of 1)     Comments (0)    

Related Topic (s) in Programming section.

Austin software design

1.3K views5 years ago

Austin Design Studio • Enterprise Software Companies • Innovation Consulting • Rocksauce: Design thinking methodology ...[Read more]


Telegram @trapbest420 Buy Weed Cocaine Thc vapes in Hanover

12 views2 days ago

Telegram @trapbest420 Buy Weed Cocaine Thc vapes in Hanover


The Future of Cutting-Edge App Development: Key Trends

170 views4 months ago

Cutting-edge app development is at the forefront of innovation, and staying updated with the latest ...[Read more]