how to remove variables after viewing the database using CORONA?

same like this:

for row in db:nrows("SELECT * FROM test ORDER BY content desc LIMIT 15 ") do
  local t = display.newText(row.content, 20, 30 * row.id, null, 16)
 – t:setTextColor(255,0,255)

    count = count +1
  local txts = row.content…"                   "…row.content2

 viewdata = display.newText(txts, 100, 65 + (20 * count), native.systemFont, 20)
 viewdata:setTextColor(255,0,255)
end
 

how to remove viewdata ?

when i use

viewdata:removeself()

viewdata = nil… 

its not functioning…

That’s because you’re only keeping the last reference to ‘viewdata’. 

One way would be to insert the texts into a display group.

Something like this:

local count = 0 local viewGroup = display.newGroup() for row in db:nrows("SELECT \* FROM test ORDER BY content desc LIMIT 15 ") do local t = display.newText(row.content, 20, 30 \* row.id, native.systemFont, 16) -- t:setTextColor(255,0,255) count = count + 1 local txts = row.content.." "..row.content2 local viewdata = display.newText(viewGroup, txts, 100, 65 + (20 \* count), native.systemFont, 20) viewdata:setTextColor(255,0,255) end viewGroup:removeSelf() viewGroup = nil

thank you sir ingemar

 :)

i use this to remove

 group:insert( viewGroup)

That’s because you’re only keeping the last reference to ‘viewdata’. 

One way would be to insert the texts into a display group.

Something like this:

local count = 0 local viewGroup = display.newGroup() for row in db:nrows("SELECT \* FROM test ORDER BY content desc LIMIT 15 ") do local t = display.newText(row.content, 20, 30 \* row.id, native.systemFont, 16) -- t:setTextColor(255,0,255) count = count + 1 local txts = row.content.." "..row.content2 local viewdata = display.newText(viewGroup, txts, 100, 65 + (20 \* count), native.systemFont, 20) viewdata:setTextColor(255,0,255) end viewGroup:removeSelf() viewGroup = nil

thank you sir ingemar

 :)

i use this to remove

 group:insert( viewGroup)