Insert Multiple Rows Using Same/Single Id In PHP

Bipsmedium
3 min readAug 1, 2020
Insert Multiple Rows Using Same/Single Id In PHP

In this tutorial, we will learn how to insert multiple rows using same id in php. For example, we have some fruit items like orange, mango, banana etc. Now, we will consider the fruit as item category and fruit-related items as fruit subcategory. We will insert all the subcategory items using the parent category inside the mysql database. I hope it’s clear.

Next, we will select the parent category as shown in the above image and create the multiple subcategories with the help of jquery so that we can insert the multiple subcategories under one category.

Now, we will create multiple rows for subcategories with jquery. If you don’t know then read also, how to create multiple rows using jquery.

Insert data into the database after the form submission

  • When we submit the form data then the parent category will be inserted into a table name ‘items’ in the database and the subcategories will be inserted into another table ‘item_details’ using the category id from the ‘items’ table.

--

--

Bipsmedium
Bipsmedium

Written by Bipsmedium

Hi, This is Biplab and I am a PHP laravel developer and other open source technologies. I am here to share my experience with the community.

No responses yet