Welcome Guest, Not a member yet? Register   Sign In
whi table generate extra <td>?
#1

[eluser]xpacio[/eluser]
my code:

Code:
$bancos=array('banamex','bancomer','hsbc','santander');
$tipo= array('ui/img/money.png','ui/img/monitor_go.png');
$campos = array('fecha_deposito','fecha_registro','banco','monto','folio','tipo','ficha','user_id');
#selecciona los campos para el usuario actual
$this->db->select($campos);
$this->db->where('estado', 0);
$query = $this->db->get( 'depositos');
if ( $query->num_rows() > 0 )
{
    $this->load->library('table');
    $this->table->clear();
    $this->table->set_heading($campos);
    $pendientes = $query->result_array();
    foreach( $pendientes as $row )
    {
        #modifica monto, concatena signo de pesos
        $row['monto'] = '$'.$row['monto'];
        #modificar banco sustituye valor por texto
        $row['banco'] = $bancos[$row['banco']];
        #modifica ficha, sustituye por icono, agrega enlace
        $row['ficha'] = anchor('fichas/show/'.$row['ficha'],img('ui/img/image_link.png'));
        #modifica tipo, sustituye por icono.
        $row['tipo'] = img($tipo[$row['tipo']]);
        #agrega columna para control

        #variable para vista
        $this->table->add_row($row);
    }
$data['pendientes'] = $this->table->generate();

and the html result:
no post beacause of spam and my few post activity

an screen to explain the problem:
http://www.imagengratis.org/?v=wrongtable.jpg

the fix i find is set $campos = array('','fecha_deposito','fecha_registro','banco','monto','folio','tipo','ficha','user_id');

what is wrong?
#2

[eluser]sangprabo[/eluser]
Your query may result the extra 'field'. Try to echo the $pendientes = $query->result_array(); before adding more field. If you want only 8 field, so your query result should not be more than 4 fields (monto, banco, ficha and tipo is 4 fields).
#3

[eluser]xpacio[/eluser]
tanks sangprabo i apreciate you aswer; the result is ok, i miss with function add_row(), may be a bug, any way y fixed making new array and pasing directly to table->generate(). (sorry for my bad english).


Code:
public function historial ()
    {
        $this->_acl(1,'session');
        $data=null;
        $bancos=array('Banamex','Bancomer','HSBC','Santander');
        $tipo= array(0=>'ui/img/money.png',1=>'ui/img/monitor_go.png');
        $campos = array('fecha_deposito','banco','monto','folio','tipo','ficha','estado');
        $alt_estados = array ('validando','rechazado','aplicado');
        $estados = array ('time.png','cancel.png','accept.png');
        #selecciona los campos para el usuario actual
        $this->db->select($campos);
        $this->db->where('user_id', $this->session->userdata('id'));
        $query = $this->db->get( 'depositos');
        if ( $query->num_rows() > 0 )
        {
            $this->load->library('table');
            $this->table->clear();
            $this->table->set_heading($campos);
            $historial = $query->result_array();
            $list = null;
            foreach( $historial as $row )
            {
                #modifica monto, concatena signo de pesos
                $row['monto'] = '$'.$row['monto'];
                #modificar banco sustituye valor por texto
                $row['banco'] = $bancos[$row['banco']];
                #modifica ficha, sustituye por icono, agrega enlace
                $row['ficha'] = anchor('fichas/show/'.$row['ficha'],img('ui/img/image_link.png'));
                #modifica tipo, sustituye por icono.
                $row['tipo'] = img($tipo[$row['tipo']]);
                #modifica estado, sustituye por icono.
                $row['estado'] = img('ui/img/'.$estados[$row['estado']]);
                #modifica user_id, usutituye por nombre de usuario
                
                #variable para vista
                $list[]=$row;
            }
            $data['depositos'] = $this->table->generate($list);
        }
        $this->_render($data);
    }
codeingniter reactor rocks!.




Theme © iAndrew 2016 - Forum software by © MyBB