The PHP code ignoring my first input

QuarTz08

New Member
I write this code to take the tasks and their no from user \[code\]<form method="POST" action="add.php"> <tr> <td colspan="4">Tasks</td> </tr> <tr> <td colspan="4"> <div id="tasksInput"> Task Name<input type="text" name="mytasks[]"/> No <input type="text" name="myvol[]"/> <input type="button" value="http://stackoverflow.com/questions/15899592/add" onClick="add('tasksInput');"> </div> </td> </tr><input type="submit"/> </form>\[/code\]Java script "tasksInput" function is \[code\]<script type="text/javascript">var count = 1;var limitt = 100;function add(divName2){ if (count == limitt) { alert("You have reached the limit of adding " + count + " inputs"); } else { var newdiv2 = document.createElement('div'); newdiv2.innerHTML = "Task " + (count + 1) + " <input type='text' name='mytask[]'>" + "No <input type='text' name='myvol[]'/>"; document.getElementById(divName2).appendChild(newdiv2); count++; }}</script>\[/code\]when i click submit, he must store the task in db, lets say i will store A 1B 2C 3in DB he will store only the Task B and C and The no 1 , 2Could you help me plzhere is my php code \[code\]$needs=$_POST['mytask'];$no=$_POST['myvol'];$N = count($needs);if(! empty($_POST['mytask'])){ for($i=0; $i < $N; $i++) { $needname = $needs[$i]; $noneed= $no[$i]; if(! empty($needname )) { $query2=mysql_query("INSERT INTO projecttasks VALUES('','','$needname',' $noneed','')"); } }}\[/code\]
 
Back
Top