[eluser]dunken[/eluser]
Hello.
Can some1 tell me what i am doing wrong. I get duplicates in the second array.
code:
Code:
function get_documents($section){
$query = $this->db->query("SELECT DISTINCT flow FROM documents WHERE section = '$section' ORDER BY flow ASC");
foreach($query->result_array() as $row)
{
$flowName = $row['flow'];
$query2 = $this->db->query("SELECT * FROM documents WHERE section = '$section' AND flow = '$flowName' ORDER BY date DESC");
foreach($query2->result_array() as $row2)
{
$flows[] = array
(
'date' => $row2['date'],
'user' => $row2['user'],
'header' => $row2['header'],
'flow' => $row2['flow'],
'section' => $row2['section'],
'document' => $row2['document']
);
}
$arrFlows[$flowName] = $flows;
}
return $arrFlows;
}
after putting some test data in it, i get this.
Code:
Array
(
[TestFlöde] => Array
(
[0] => Array
(
[date] => 1259077792
[user] => 1
[header] => crazy christmas
[flow] => TestFlöde
[section] => hoga_radet
[document] => Crazy_Christmas_2.doc
)
[1] => Array
(
[date] => 1259074844
[user] => 1
[header] => fvsd
[flow] => TestFlöde
[section] => hoga_radet
[document] => avatar.jpg
)
)
[TestFlöde2] => Array
(
//from here
[0] => Array
(
[date] => 1259077792
[user] => 1
[header] => crazy christmas
[flow] => TestFlöde
[section] => hoga_radet
[document] => Crazy_Christmas_2.doc
)
[1] => Array
(
[date] => 1259074844
[user] => 1
[header] => fvsd
[flow] => TestFlöde
[section] => hoga_radet
[document] => avatar.jpg
)
//to here
[2] => Array
(
[date] => 1259079232
[user] => 1
[header] => nytt dokument
[flow] => TestFlöde2
[section] => hoga_radet
[document] => crazy_cristmaz_2009_first.jpg
)
[3] => Array
(
[date] => 1259078001
[user] => 1
[header] => bombay
[flow] => TestFlöde2
[section] => hoga_radet
[document] => bombay.txt
)
)
)
as u can see the mark text has already been written to the first array, why is it in the second as well?
thanks for understanding my English