Welcome Guest, Not a member yet? Register   Sign In
Array issue
#1

[eluser]sinvos[/eluser]
Trying to change some data that gets returns using $query->result_array()
Code:
Foreach($query->result_array() as $row)
     {
        $row['name'] = '<input type="text" name="name" value="'.$row['name'].'" size="13" />';
     }
     echo $this->table->generate($query);
My understanding should have worked but nothing happens and table populates normally. So i tried a different way
Code:
Foreach($query->result_array() as $row)
     {
       $data[]=$row
       $data['name']='<input type="text" name="name" value="'.$row['name'].'" size="13" />';
     }

  echo $this->table->generate($data);
Now the data is mixed and it only returns 2 rows none of which is header. So whats the proper way of making this happen??
Thanks in advance.
#2

[eluser]cahva[/eluser]
Havent used the table class but you could try the second way like this:
Code:
$data = array();
Foreach($query->result_array() as $row)
{
    $row['name'] = '<input type="text" name="name" value="'.$row['name'].'" size="13" />';
    $data[]=$row
}

echo $this->table->generate($data);
If you dont get the headers(as I think you wont), you can pass the headers where I initialized the $data array.
For examle:
Code:
$data = array( 0 => array('Name','Age','Sex','Email'));
#3

[eluser]xwero[/eluser]
You can always use the set_heading method of the table class
#4

[eluser]sinvos[/eluser]
Thanks cahva that did the trick.




Theme © iAndrew 2016 - Forum software by © MyBB