nyther Posted July 21, 2014 Share Posted July 21, 2014 Hey guys,I am trying to input data into a mysql database from data thats been added by a jquery form with cloned fields. It is working however it adds the first row correctly then a blank row and then the rest of the rows correctlyThe code is this$x=0;do {$fga=$_POST['ID'.$x.'fga'];$fgm=$_POST['ID'.$x.'fgm'];$fta=$_POST['ID'.$x.'fta'];$ftm=$_POST['ID'.$x.'ftm'];$tpa=$_POST['ID'.$x.'tpa'];$tpm=$_POST['ID'.$x.'tpm'];$fta=$_POST['ID'.$x.'fta'];$ftm=$_POST['ID'.$x.'ftm'];$stl=$_POST['ID'.$x.'stl'];$trb=$_POST['ID'.$x.'trb'];$ast=$_POST['ID'.$x.'ast'];$blka=$_POST['ID'.$x.'blka'];$blkf=$_POST['ID'.$x.'blkf'];$tovr=$_POST['ID'.$x.'tovr'];mysql_query("INSERT INTO stats (gameId, fga, fgm, tpa, tpm, fta, ftm, ast, stl, trb, blka, blkf, tovr) VALUES ('$gameId', '$fga', '$fgm', '$tpa', '$tpm', '$fta', '$ftm', '$ast', '$stl', '$trb', '$blka', '$blkf', '$tovr')")or die("<div class='errmsg'>Insert Error: ".mysql_error()."</div><br /> \n");$x++;Can anyone see what ive done wrong?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/290033-adding-to-mysql-with-loop/ Share on other sites More sharing options...
mac_gyver Posted July 21, 2014 Share Posted July 21, 2014 your client-side code is likely skipping or overwriting the first dynamic/cloned form field key/index. you can examine the submitted data by adding the following to your php code - echo '<pre>',print_r($_POST,true),'</pre>': Quote Link to comment https://forums.phpfreaks.com/topic/290033-adding-to-mysql-with-loop/#findComment-1485801 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.