Php missing first row checkbox values in dynamic table, when inserting to mysql? -


update, have found answer, see below...

dynamic table of around 70 lines, user enters order size , selects checkbox (which has value) , submits table. enters mysql fine except values of checkboxes on first line, (they 0.000), acct id , order size first line enter fine, checkboxes reason. checkbox lines 2-70 work fine. i've totally confused myself, ideas?

//php start if ((isset($_post["mm_insert"])) && ($_post["mm_insert"] == "form2")) {  mysql_select_db($database_demo_db01, $demo_db01);  //loop through input values ($i = 0, $len = count($_post['demo_acct_id']); $i < $len; $i++) {  //this trims empty value lot_size column if(trim($_post['lot_size'][$i]) !== ''){             $insertsql = sprintf("insert demo_order (demo_acct_id_fk, demo_order_size,      demo_order_symbol, demo_order_bid, demo_order_ask) values (%s, %s, %s, %s, %s)",                    getsqlvaluestring($_post['demo_acct_id'][$i], "int"),                    getsqlvaluestring($_post['lot_size'][$i], "double"),                    getsqlvaluestring($_post['pair'][$i], "text"),                    getsqlvaluestring($_post['checkbox'][$i], "double"),                    getsqlvaluestring($_post['checkbox2'][$i], "double"));     $result1 = mysql_query($insertsql, $demo_db01) or die(mysql_error());     }//end loop    $insertgoto = "pairs_prices.php";   if (isset($_server['query_string'])) {     $insertgoto .= (strpos($insertgoto, '?')) ? "&" : "?";     $insertgoto .= $_server['query_string'];   }   header(sprintf("location: %s", $insertgoto)); } }  <!--html-->               <td><?php echo $row_p_p['pair']; ?>                 <input name="demo_acct_id[]" type="hidden" id="demo_acct_id" value="<?php echo $row_d_a['demo_acct_id']; ?>">                 <input name="pair[]" type="hidden" id="pair" value="<?php echo $row_p_p['pair']; ?>"></td>               <td><label for="lot_size"></label>                 <input name="lot_size[]" type="text" id="lot_size" size="5"></td>               <td><label for="checkbox"></label>               <input type="hidden" name="checkbox[<?php echo $i; ?>]" value="0">           <input name="checkbox[<?php echo $i++; ?>]" type="checkbox" class="example" id="checkbox" value="<?php echo $row_p_p['bid']; ?>">              <?php echo $row_p_p['bid']; ?></td>           <td><label for="checkbox2"></label>             <input type="hidden" name="checkbox2[<?php echo $j; ?>]" value="0">             <input name="checkbox2[<?php echo $j++; ?>]" type="checkbox" class="example" id="checkbox2" value="<?php echo $row_p_p['ask']; ?>" >             <?php echo $row_p_p['ask']; ?></td> 

answer: in checkbox html, there hidden input each of 2 checkboxes, have check if checkbox clicked, selected rows checkbox checked gets submitted db table. have moved hidden field before checkbox value after checkbox value. checkbox value first row returned db table.

only first line having issue ?

for ($i = 0, $len = count($_post['demo_acct_id']); $i < $len; $i++) { 

change to

for ($i = 1, $len = count($_post['demo_acct_id']); $i < $len; $i++) { 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -