I have this javascript function it creates a form containing the same information
function aTask(){
var noTask = parseInt(document.getElementById("nwTask").value);
var out = "<form action = \"\" method = \"POST\">"
for (var x = 0 ; x < noTask ; x++){
out = out + "Task Name: <input type = \"text\" id = \"taskName\" class = \"taskInp\" name = \"taskName[]\"><br />"
out = out + "Task Description: <input type = \"text\" id = \"taskDesc\" name = \"taskDesc[]\"><br />"
out = out + "Task Deadline: <input type = \"date\" id = \"taskDead\" name = \"taskDead[]\"><br /><hr>"
}
out = out + "</form>"
document.getElementById("taskList").innerHTML = out
}
My problem is I don't know how to out the input information in the database and a user may ask up to 10 of this fields.
My question is I made a dynamic form with same names and type , how am I gonna store it to the database?
This is what I have right now and nothing is happening
if (isset($_POST["saveNTask"]) && isset($_POST["newTask"])){
$inpCount = $_POST['newTask'];
for ($i = 0 ; $i < $inpCount; $i++){
addProj($_POST["taskName"], $_POST["taskDesc"],$_POST["taskDead"]);
}
}else{
echo "damn";
}
Thanks to anyone who has time to read and/or answer this question My database right now is a simple one it has one table name task_tbl it will become a relational database in the future but right now I want to learn how to handle this type of programming problems
I forgot to post the query
function addProj ($projName, $projDesc, $projDeadLine){
$date = $projDeadLine;
$query = "INSERT INTO task_tbl (task_name , task_desc,task_dateAssign,task_deadline, task_status) VALUES('"+$projName+"','"+$projDesc+"','"+$date+"','"+$projDeadLine+"','"+ToDo+"')";
mysqli_query($con,$query);
mysqli_close($con);
}