Jump to content

Recommended Posts

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 correctly

The 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

Link to comment
https://forums.phpfreaks.com/topic/290033-adding-to-mysql-with-loop/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.