Display SQL Lite Records with Images one after the other

Hi,
I am trying to pull out records from a SQL Lite database and display records where their pic is against their name and city, very similar to the Coffee Demo in Corona Tutorials.

But somehow I am not getting the display past the first record.

If the search returns one record the display is fine, but if there are more than 1 records, the next record is overlapping the previous one.

Stuck at it, please help, i am a newbie.

Thanks
Sunil [import]uid: 56933 topic_id: 12294 reply_id: 312294[/import]

Post the code you have so we can better help you.

I presume you mean the images are overlapping and not the records. It may just be something like you’re not incrementing the x or y coordinate value enough on each iteration of the loop. [import]uid: 26769 topic_id: 12294 reply_id: 44817[/import]

Thanks for the prompt response. The code as requested

for row in db:nrows(“SELECT * FROM test where city=’”…stock…"’") do

–Code to display the image from DB.

local idtext = row.photo
local img = display.newImage(idtext,10,0 + (10 * row.id))
Display.group:insert(img)
idtext = nil

–Code to display name from DB

local idtext = row.name
local idt = display.newText(idtext, 130, 80 + (10 * row.id), native.systemFontBold, 20)
local idt = display.newText(idtext, 0, 0 + (5 * row.id), native.systemFontBold, 20)
idt:setTextColor(255,255,255)
Display.group:insert(idt)
idt.x = idt.width*0.5 + img.width + 15
idt.y = idt.y + idt.height + 6
idtext = nil

–Code to display city from DB

local idtext = row.city
local idcity = display.newText(idtext, 135, 120 + (10 * row.id), native.systemFont, 14)
idt:setTextColor(255,255,255)
Display.group:insert(idcity)
idcity.x = idcity.width*1.5 + img.width + 15
idcity.y = idt.y + idt.height + 6
idtext = nil

end

If there are multiple records for the search, i am unable to display the records one below the other.

Also i wish to add a event such that clicking on the record will open a new screen and show more data from the DB.

Help is very much appreciated. [import]uid: 56933 topic_id: 12294 reply_id: 44834[/import]

Thanks for the code. Try using the code tags on the forum so that your code appears like below:

local someVariable = "Hello"  

My first thought is that you’re not updating the y value correctly on each iteration. Try outputting the y values to the terminal before use so you can check they are indeed correct. The part of your code “to display name from DB” uses the idt variable twice. Is that correct?

To add a click event to an object, use something like:

[code]

– Define a function to hold code to respond to the touch
local function myTouchEvent(event)
– My code here

end
– The code below should be added to your code above after you’ve created the object you want to click on
idtext:addEventListener(“touch”, myTouchEvent)
[/code] [import]uid: 26769 topic_id: 12294 reply_id: 44837[/import]