Hello Friends This tutorial is concerned with inserting or deleting html input dynamically using Jquery Ajax with PHP MySql. Users can enter more than one data at a time. Users can add bulk data at once. The data will be inserted with the refresh of the outgoing page because we use the ajax function call to enter the data. Users can add more fields by clicking the add more button then a new textbox will appear on the web page with the delete button. If the user wants to delete some fields then it can delete the input field on click on the delete button. Now, one day this functionality is very useful in web applications.
Source Code Dynamic add or remove input fields with Jquery Ajax
index.php
Dynamically Add or Remove input fields in PHP with JQuery
name.php
$connect = mysqli_connect("localhost", "root", "", "test_db");
$number = count($_POST["name"]);
if($number > 0)
{
for($i=0; $i<$number; $i++)
{
if(trim($_POST["name"][$i] != ''))
{
$sql = "INSERT INTO tbl_name(name) VALUES('".mysqli_real_escape_string($connect, $_POST["name"][$i])."')";
mysqli_query($connect, $sql);
}
}
echo "Data Inserted";
}
else
{
echo "Please Enter Name";
}
?>