Edit data in a table in php.

0

What happens is that I need to edit different data within a table, but I do not know how to do it. Let's say that this is the table:

Descripción    Cantidad

Mundo             10
Hola              20 

What I want is to be able to edit let's say ten for a 5 and 20 for an eight, that is, to be able to edit the data in the table.

This is the code of the view:

<div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">Editar Requisicion</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
               <div class="panel panel-default">
                        <div class="panel-heading">
                            Requisición
                        </div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-12">
                                    <form role="form" name="frm_ciudad" method="post" action="<?php echo getUrl("Requisicion","requisicion","postEditar"); ?>">


                               <table>
                                        <table class="table table-bordered jambo_table bulk_action">
                                              <thead>
                                                <tr class="headings">
                                                    <th>Item</th>
                                                    <th>Cantidad</th>
                                                    <th>Unidad</th>
                                                    <th>Descripción</th>
                                                    <th>Longitud</th>
                                                    <th>Obra Codigo</th>
                                                    <th>Proveedor   </th>
                                                    <th>Valor Unitario</th>
                                                    <th>Valor Total</th>
                                                  </tr>
                                              </thead>
                                              <tbody id="requi">
                                                  <?php                
                                                      foreach ($producto as $productos) 
                                                      {
                                                        echo"<tr>";
                                                            echo"<td><input readonly value=".$productos['item']."></td>";
                                                            echo"<td><input name='cantidad_req' value=".$productos['cant_re']."></td>";

                                                            echo"<td>".$productos['unidad']."</td>";
                                                            echo"<td>".$productos['des_re']."</td>";
                                                            echo"<td>".$productos['longitud']."</td>";
                                                            echo"<td>".$productos['obra']."</td>";
                                                            echo"<td>".$productos['nombre_pro']."</td>";
                                                            echo"<td>".$productos['valor_u']."</td>";
                                                            echo"<td>".$productos['valor_total']."</td>";

                                                        echo"</tr>";             
                                                      }
                                                  ?>
                                              </tbody>
                                            </table>                 



                                       <div class="form-group">
                                            <label>Consecutivo</label>
                                          <input class="form-control" name="conse" value="<?php echo $productos[2]?>">
                                      </div>
                                      <div class="form-group">
                                            <label>Tipo doc</label>
                                          <input class="form-control" name="oc" value="oc">
                                      </div>


                                        <div class="form-group">
                                            <label>Fecha</label>
                                          <input class="form-control" name="fechar"  value="<?php echo $productos[10]?>">
                                      </div>

                                         <div class="form-group">
                                            <label>Solicitado por</label>
                                            <input class="form-control" name="solici"  value="<?php echo $productos[11]?>">
                                        </div>

                                        <div class="form-group">
                                            <label>Ultima Fecha Para Entrega</label>
                                            <input class="form-control" name="fech"  value="<?php echo $productos[9]?>">
                                        </div>
                                         <div class="form-group">
                                            <label>Proveedor</label>
                                            <input class="form-control" name="provee"  value="<?php echo $productos[14]?>">
                                        </div>
                                         <div class="form-group">
                                            <label>Tipo</label>
                                            <input class="form-control" name="tipor"  value="<?php echo $productos[13]?>">

                                        </div>

                                         <div class="form-group">
                                            <label>Estado</label>
                                            <input class="form-control" name="estado" disabled value="<?php echo $productos[17]?>">
                                        </div>
                                         <div class="form-group">
                                            <label>Observación</label>
                                            <input class="form-control" name="observa"  value="<?php echo $productos[18]?>">
                                        </div>





                                        &nbsp; &nbsp;&nbsp;<button type="submit" class="btn btn-info btn-lg">Editar</button>
                                        <button class="btn btn-danger btn-lg"><a href="<?php echo 
                                        getUrl("Requisicion","requisicion","listar"); ?>" style="color:#FFF">Cancelar</a></button>
                                    </form>
                                </div>
                            </div>
                            <!-- /.row (nested) -->
                        </div>
                        <!-- /.panel-body -->
                    </div> 
            </div>
</div> 

and this is the code of the controller that when executing it puts the data in 0.

 function postEditar(){

            @$a=$_POST['a'];
            if (empty($a)){
                $a=1;
            }
            @$consecu=$_POST['conse'];
            $fechai=$_POST['fechar'];
            $tipos=$_POST['tipor'];
            $solicitante=$_POST['solici'];





            $ultf=$_POST['fech'];


            $obs=$_POST['observa'];
            @$est=$_POST['estado'];
            $consecu=$_POST['conse'];
            //$canti=$_POST['cantidad_req'];





            $sql="update requisicion_admi set fecha_requi='$fechai', tipo='$tipos', fecha_ult='$ultf', encargado='$solicitante', observa='$obs', cant_re='".$_POST['cantidad_req']."'" . "where consecutivo='$consecu'";
            $objUsu= new requisicionModel();
            $producto=$objUsu->Actualizar($sql);
            $objUsu->closeConect();
            //redirect(getUrl("Requisicion","requisicion","listar"));


} 

What should I do?

    
asked by María J. Reyes 24.05.2018 в 16:28
source

0 answers