Using dynamic textbox to add lot of data into table on same id

     

I have a table whose column names are h1 to h40. I am using dynamic text box method. According to my image i will enter data in textbox will save it with save button and with + sign I will add new text box. On submitting first data it will be inserted to h1 and on adding second textbox h2 to h40 will be updated. but I am not getting success. How to achieve it?


if (isset($_POST['save'])) {   $n = $_POST['textbox'];   echo $n;   $query = mysqli_query($bd "INSERT INTO col_heading1(h1) VALUES('$n')") or die("error in $query == ----> " . mysqli_error($bd));   $lastid = mysqli_insert_id($bd);   header('location:column.php');  } //echo $lastid; if(isset($_POST['update'])) { $n= $_POST['textbox']; echo $n; $query = mysqli_query($bd"UPDATE col_heading1 SET h2='$n'") or die("error in $query == ----> ".mysqli_error($bd)); header('location:column.php'); } ?>