Hi guys. I have this form. Show records, checkbox, code and name, but name can be changed. I want to change some records but only if it had checked first. <form name="cambio_nombre" class="" action="index.php?action=subirCargos4" method="POST" enctype="multipart/form-data"> <table id="miTabla" class="table table-striped table-bordered table-hover table-condensed"> <tr id="cabecera" class="active"> <th>Update</th> <th>Code</th> <th>Name in Master</th> <th>New Name</th> </tr> {section name=i loop=$lista} <tr class="success"> <td><input type="checkbox" name="codigo[]" id="codigo" value="{$lista[i]->codigo}"></td> <td>{$lista[i]->codigo}</td> <td>{$lista[i]->nombre_old}</td> <td><input type="text" name="nombre" id="nombre" value="{$lista[i]->nom_new}"></td> </tr> {/section} </table> <div class="modal-footer"> <button class="btn btn-primary">Procesar</button> </div> </form> HTML: For example: First: chk code name [ ] 100 paolo [ ] 200 pedro [ ] 300 rose [ ] 400 sean checked: chk code name [x] 100 linda [ ] 200 pedro [x] 300 frank [ ] 400 sean When I push a button, php file receive an array to update that records. What need to change in my form to get that?
$codigo = $_POST['codigo']; Code (markup): in the php The $indigo will automatically be an array You can even do it print_r command to check it
In the view <input type="text" name="nombre" id="nombre" value="{$lista[i]->nom_new}"> HTML: I can to change the NAME. But codigo[] HTML: pass only the codes. If I use nombre[] HTML: In php file receive: codigo[] only codes checked, but nombre[] get all nombres in list. And I need only nombre[] was checked.
<td><input type="text" name="nombre" id="nombre" value="{$lista[i]->nom_new}"></td> Code (markup): you have nombre as type = "text", it should be "checkbox" right?