Welcome Guest, Not a member yet? Register   Sign In
How to get single value from $fields = $this->db->field_data($table);
#1

[eluser]Julia Yan[/eluser]
------------models
$fields = $this->db->field_data($table);

foreach ($fields as $row){
if ($row->type=='string') $row->len = $row->len/3; //utf8
$rows[] = $row;
}
// the red code does not get value? how to make the right code?
$form_data = array(
'id' => array('type'=>'input', 'size'=>20,'maxlength'=>$field['id']->len,'value'=>$value['id'],'name'=>'id','id'=>'id','readonly'=>'readonly' ),
'name' => array('type'=>'input', 'size'=>20,'maxlength'=>$field['name']->len,'value'=>$value['name'],'name'=>'name','id'=>'name' )
)

PS field len from other class
#2

[eluser]smilie[/eluser]
Well, you have:

fieldS (note S at the end);

but in your form_data you are using field (note there is NO S at the end)?

Cheers,
Smilie
#3

[eluser]Julia Yan[/eluser]
[quote author="smilie" date="1290020393"]Well, you have:

fieldS (note S at the end);

but in your form_data you are using field (note there is NO S at the end)?

Cheers,
Smilie[/quote]

Thanks, would you please sample?
#4

[eluser]sqwk[/eluser]
'field' != 'fields'

Updated code:

Code:
$fields = $this->db->field_data($table);

foreach ($fields as $row){
        if ($row->type==‘string’) $row->len = $row->len/3; //utf8
        $rows[] = $row;
}

‘id’    => array(‘type’=>‘input’, ‘size’=>20,‘maxlength’=>$fields[‘id’]->len,‘value’=>$value[‘id’],‘name’=>‘id’,‘id’=>‘id’,‘readonly’=>‘readonly’ ),
‘name’  => array(‘type’=>‘input’, ‘size’=>20,‘maxlength’=>$fields[‘name’]->len,‘value’=>$value[‘name’],‘name’=>‘name’,‘id’=>‘name’ )
#5

[eluser]Julia Yan[/eluser]
[quote author="squawk" date="1290051510"]'field' != 'fields'

Updated code:

Code:
$fields = $this->db->field_data($table);

foreach ($fields as $row){
        if ($row->type==‘string’) $row->len = $row->len/3; //utf8
        $rows[] = $row;
}

‘id’    => array(‘type’=>‘input’, ‘size’=>20,‘maxlength’=>$fields[‘id’]->len,‘value’=>$value[‘id’],‘name’=>‘id’,‘id’=>‘id’,‘readonly’=>‘readonly’ ),
‘name’  => array(‘type’=>‘input’, ‘size’=>20,‘maxlength’=>$fields[‘name’]->len,‘value’=>$value[‘name’],‘name’=>‘name’,‘id’=>‘name’ )
[/quote]

Thanks lots




Theme © iAndrew 2016 - Forum software by © MyBB