In my SQLite
database (FMDB
) i have some attributes as listed below;
Module | Student1 | Student2 | Student3 | Student4 | Student5
One Module
may have a minimum of 2 students
and a maximum of 5 students
. So based on the number of students i have to display Buttons.
If the number of student are 3, then i should display 3 buttons. For Ex : if the database entry is as
Science | jack | Tom | - | Debra | -
note that the - sign is an empty record. So if we come across a entry with - sign we have to ignore it. So according to the above query we have 3 students and we should display 3 buttons. (If there were 4 students we should display 4 buttons and etc...)
How could i read the values from the database, and base on that answer add buttons to the UI ?
note: I don't have any proper code to demonstrate my working. I am lost in this.
Ok, So first learn about interacting with with a SQLite FMDB Here
Then, create some kind of for loop combining the code from here and here to create UIButtons and add them to an array, then displaying only the UIButtons in the array.
The positioning of the buttons onscreen is just a bit of simple math.