Logic issue, adding Buttons to UI based on database entries

Go To StackoverFlow.com

0

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.

2012-04-04 16:33
by shajem


1

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.

2012-04-04 17:58
by dudeofea
You have posted the same links. Could you repost the correct link - shajem 2012-04-04 18:11
fixed the links. It was missing the one showing how to store it in an array - dudeofea 2012-04-04 18:57
Ads