[eluser]smash120[/eluser]
Hello I am new to codeigniter, I am working on my first project and I have hit a road block. The issue is that I am joining three tables using the db functions and the results being pulled in are as follows
Code:
array
0 =>
array
'account_num' => string '1' (length=1)
'icd9_code' => string '1' (length=1)
'dob' => string '12-12-1955' (length=10)
'sex' => string 'Male' (length=4)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 1' (length=8)
1 =>
array
'account_num' => string '1' (length=1)
'icd9_code' => string '1' (length=1)
'dob' => string '12-12-1955' (length=10)
'sex' => string 'Male' (length=4)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 2' (length=8)
2 =>
array
'account_num' => string '1' (length=1)
'icd9_code' => string '1' (length=1)
'dob' => string '12-12-1955' (length=10)
'sex' => string 'Male' (length=4)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 3' (length=8)
3 =>
array
'account_num' => string '1' (length=1)
'icd9_code' => string '1' (length=1)
'dob' => string '12-12-1955' (length=10)
'sex' => string 'Male' (length=4)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 4' (length=8)
4 =>
array
'account_num' => string '2' (length=1)
'icd9_code' => string '2' (length=1)
'dob' => string '11-11-1958' (length=10)
'sex' => string 'Female' (length=6)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 1' (length=8)
5 =>
array
'account_num' => string '2' (length=1)
'icd9_code' => string '2' (length=1)
'dob' => string '11-11-1958' (length=10)
'sex' => string 'Female' (length=6)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 3' (length=8)
6 =>
array
'account_num' => string '2' (length=1)
'icd9_code' => string '2' (length=1)
'dob' => string '11-11-1958' (length=10)
'sex' => string 'Female' (length=6)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 4' (length=8)
7 =>
array
'account_num' => string '3' (length=1)
'icd9_code' => string '3' (length=1)
'dob' => string '03-11-1958' (length=10)
'sex' => string 'Female' (length=6)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 3' (length=8)
8 =>
array
'account_num' => string '3' (length=1)
'icd9_code' => string '3' (length=1)
'dob' => string '03-11-1958' (length=10)
'sex' => string 'Female' (length=6)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 4' (length=8)
I managed to loop thru to get the output to display as follows
Code:
array
'account_num' => string '1' (length=1)
'dob' => string '12-12-1955' (length=10)
'sex' => string 'Male' (length=4)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 1' (length=8)
array
'account_num' => string '1' (length=1)
'dob' => string '12-12-1955' (length=10)
'sex' => string 'Male' (length=4)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 2' (length=8)
array
'account_num' => string '1' (length=1)
'dob' => string '12-12-1955' (length=10)
'sex' => string 'Male' (length=4)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 3' (length=8)
array
'account_num' => string '1' (length=1)
'dob' => string '12-12-1955' (length=10)
'sex' => string 'Male' (length=4)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 4' (length=8)
array
'account_num' => string '2' (length=1)
'dob' => string '11-11-1958' (length=10)
'sex' => string 'Female' (length=6)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 1' (length=8)
array
'account_num' => string '2' (length=1)
'dob' => string '11-11-1958' (length=10)
'sex' => string 'Female' (length=6)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 3' (length=8)
array
'account_num' => string '2' (length=1)
'dob' => string '11-11-1958' (length=10)
'sex' => string 'Female' (length=6)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 4' (length=8)
array
'account_num' => string '3' (length=1)
'dob' => string '03-11-1958' (length=10)
'sex' => string 'Female' (length=6)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 3' (length=8)
array
'account_num' => string '3' (length=1)
'dob' => string '03-11-1958' (length=10)
'sex' => string 'Female' (length=6)
'study' => string 'study 4' (length=7)
'prescription' => string 'script 4' (length=8)
As you can see some info in each array are the same I wanted to know if there is a way to consolidate this data so it display as follows
account num 1
icd9 code 1
dob 12-12-1955
sex Male
study study 2
prescriptions script 1, script 2, script 3, script 4
account num 2
icd9 code 2
dob 11-11-1958
sex Female
study study 2
prescriptions script 1, script 3, script 4
and so on
and not like this
account num 1
icd9 code 1
dob 12-12-1955
sex Male
study study 2
prescriptions script 1
account num 1
icd9 code 1
dob 12-12-1955
sex Male
study study 2
prescriptions script 2
account num 1
icd9 code 1
dob 12-12-1955
sex Male
study study 2
prescriptions script 3
account num 1
icd9 code 1
dob 12-12-1955
sex Male
study study 2
prescriptions script 4
account num 2
icd9 code 2
dob 11-11-1958
sex Female
study study 2
prescriptions script 1
and so on. I appreciate any suggestions