I am far from an expert so please take my advice with that in mind.
1st - from what i understand when you declare local - they will only be seen where they have been declared.
In this case - you appear to declare within your database for loop - thus it may fuse problems if you want to do things relating to those variables outside of the for loop.
2nd - when you say next question do you mean “Next” as in the one after current (sequentially) - or “another different” question(random)?
3rd - I assume the colours aren’t causing problems (255, 255, 255) instead of (1, 1, 1)
have never used “BY RANDOM() limit 1” before so can’t help there.
4th - You obviously want to randomise the position of the answers b/c if you don’t then player will always be touching t4 located at 200, 200.
Something to consider (but is just how i code) i like actually adding the X & Y lines separately.
t4.x = 200
t4.y = 200
by adding some randomisation to these positioning lines you won’t have to deal with tracking the correct answer touched
it will always be t4 no matter where on the screen it is located
[lua]
local sql = “SELECT * FROM QuizCorona ORDER BY RANDOM() LIMIT 1”
–n = math.random(#row.Qid) – Shows error
–print (n)
for row in db:nrows(sql) do
print (“Row=>” …row.Qid) – Able to print the Qid of the Question on display.
--c = row.Qid
– c = row.Qid +1
--Print©
local text = row.Question
local t = display.newText(text, 50, 50, native.systemFont ,14)
t:setFillColor(255,255,255)
local text1 = row.Opt1
local t1 = display.newText(text1, 50, 100, native.systemFont ,14)
t:setFillColor(255,255,255)
local text2 = row.Opt2
local t2 = display.newText(text2, 200, 100, native.systemFont ,14)
t:setFillColor(255,255,255)
local text3 = row.Opt3
local t3 = display.newText(text3, 50, 200 , native.systemFont ,14)
t:setFillColor(255,255,255)
local text4 = row.Opt4
local t4 = display.newText(text4, 200, 200, native.systemFont ,14)
t:setFillColor(255,255,255)
end
[/lua]
edit - interesting i was able to post above your post - must be a time zone thing - anyway i posted your code in the lua format to make it easier to read.