$tempfiles=array();
$i=0;
foreach ($query->result_array() as $row) {
$sql='Select * FROM file WHERE name="'.$row['filename'].'"';
$q=$this->db->query($sql);
foreach ($q->result_array() as $tuple) {
$tempfiles[$i]['content']=$tuple['content'];
$tempfiles[$i]['owner']=$tuple['content'];
$tempfiles[$i]['last_modified_date']=$tuple['last_modified_date'];
}
$i++;
}
$i=0;
$files=array();
foreach ($query->result_array() as $row) {
$files[$i]['name']=$row['filename'];
here: $files[$i]['content']=$tempfiles[$i]['content'];
here: $files[$i]['owner']=$tempfiles[$i]['owner'];
here: $files[]['last_modified_date']=$tempfiles[$i]['last_modified_date'];
$i++;
}
php error : undefined offset 0 at lines where i have mentioned ‘here’, whats the problem i cant figure it out?
/i am using codeigniter./
You should better check
in first loop that it contains any result or not.
If not, then you should not move further otherwise execute the code.
Again for next code in first foreach, check
if it contains result then move for assigning values in $tempfiles.
And for assigning values in $files, you should go like,