Okay, I have a table. Something similar to the following...
ID | name | ref_id |
1 | mark | 2 |
2 | chris | 1 |
3 | charles | 4 |
4 | don | 4 |
5 | stacy | 2 |
What I need to do is print out the names into javascript arrays. Easy enough. However, I need a different array for each ref_id group. So, it would print out as follows...
ref_id_1[0] = "chris"
ref_id_2[0] = "mark"
ref_id_2[1] = "stacy"
ref_id_4[0] = "charles"
ref_id_4[1] = "don"
Now, I can easily do this with multiple mysql statements (select name where ref_id=2, etc.). However, as the ref_id column numbers grow this method isn't practical. In addition, whatever method I use needs to be dynamic and the ref_id numbers may skip (4 -> 7).
Any ideas on how to make this more efficient?