Jump to content

holfv

New Members
  • Posts

    1
  • Joined

  • Last visited

holfv's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi. I've a form with subform (it cotains all records). I want to check and register only checked rows. The list items code is: <table id="bootstrap-data-table-export" class="table table-striped table-bordered"> <thead> <tr> <th>ADD</th> <th>CODE</th> <th>COST</th> </tr> </thead> <tbody> <?php $sql ="SELECT CODE,COST FROM PRODUCTS"; $result = sqlsrv_query($conn, $sql); $count = 0; while ($row = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC)) {?> <tr> <td><input type="checkbox" id="checkbox[<?php echo $row['CODE'];?>]" name="checkbox[<?php echo $row['CODE']; ?>]"></td> <td id="CODE" name="tableRow[<?php echo $count; ?>] " value="<?php echo $row['CODE']);?>"><?php echo $row['CODE'];?></td> <td id="COST" name="tableRow[<?php echo $count; ?>][COST]" value="<?php echo $row['COST']);?>"><?php echo $row['COST'];?></td> </tr> <?php }?> </tbody> <?php $count++; ?> </table> The code of the post is: $count = $_POST['count']; $tableRow = $_POST['tableRow']; foreach($tableRow as $row){ /* here insert the selected items (in checkbox) data from post */ $id = $row['code']; $cost = $_POST["cost"][$i]; $sentencia= "INSERT INTO LINES(code,cost) VALUES (?,?);"; $params1 = array($code,$cost); $result = sqlsrv_query($conn,$sentencia,$params1); } I think that I need a loop but I don't know if the array is OK. The post file doesn't receive nothing. I only want to register the records checked. I would greatly appreciate any kind of help.
×
×
  • 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.