Hello ,
I have this function to edit all fields that come from the form and its works fine ..
function editRow($tableName,$id)
{
$fieldsData = $this->db->field_data($tableName);
$data = array();
foreach ($fieldsData as $key => $field)
{
$data[ $field->name ] = $this->input->post($field->name);
}
$this->db->where('id', $id);
$this->db->update($tableName, $data);
}
now I want to add a condition for Password field , if the field is empty keep the old password , I did some thing like that :
function editRow($tableName,$id)
{
$fieldsData = $this->db->field_data($tableName);
$data = array();
foreach ($fieldsData as $key => $field)
{
if ($data[ $field->name ] == 'password' && $this->input->post('password') == '' )
{
$data[ 'password' ] => $this->input->post('hide_password'),
//'password' => $this->input->post('hide_password'),
}
else {
$data[ $field->name ] => $this->input->post($field->name)
}
}
$this->db->where('id', $id);
$this->db->update($tableName, $data);
}
but I get error ( Parse error: syntax error, unexpected T_DOUBLE_ARROW in ... )
Html , some thing like this :
<input type="text" name="password" value="">
<input type="hidden" name="hide_password" value="$row->$password" />
umm , any help ?
thanks ..