EventListener - Sqlite3 problems

Hi,

I am very new to Corona, and I’m trying to do a few basic things, i think i’m quite close but not exactly there.

I just want to show a list of records from an sqlite database (id,name,description).

Each of the records will be in a group which can show an image and some text and will act as a button.

Each button will have an eventlistener which when you click on it will invoke the director class and change scene (passing the id through so it can be used on the next page).

I have the following:

[lua] contentGroup=display.newGroup();
local sql=“select * from records limit 10”
for row in db:nrows(sql) do
count = count + 1;
local thisBtn = display.newGroup();
local name = display.newText(row.name,0,30+(30*count),native.systemFontBold,20);
thisBtn:insert(name);
– Add the event Listener
thisBtn:addEventListener(“touch”,changeScene);
contentGroup:insert(thisBtn);
end[/lua]

I then have my changeScene function set up but at the moment doing nothing, when I click on a button at the minute, it seems to hit it however many records I have in the db, so if I have 4 records it will go in to the function 4 times instead of just the once. How do I get this working and have access to the id within the next scene??? I am using director to change scenes.

Thanks

[import]uid: 72726 topic_id: 11860 reply_id: 311860[/import]

Just so happenend, I had 2 records in the db, and the event was firing on both press and released so looked like this behaviour when it fact it wasn’t and I just need to add:

[lua]if(e.phase==“ended”) then[/lua]

At the minute however I have a file called variables.lua that I am using to store variables that I want to use on the different screens, is this the only way of doing it, for example just before I load a scene I will do:

[lua]variables.record_id = e.target.id[/lua]

I can then access this in the same way of the following page. Is this the correct way of doing it and is it possible to have an accordion menu so I can group my records? [import]uid: 72726 topic_id: 11860 reply_id: 43206[/import]