hello…
how can i get the length of an array??
this is my code…
local function loginCallback(event)
if ( event.isError ) then
print( “Network error!”)
else
print ( "RESPONSE: " … event.response )
local data={};
data = json.decode(event.response)
– do with data what you want…
if (data.result == 200) then
– player logged in okay
print(“Success”)
print(#data.rows)
y=70;
for i = 1, #data.rows do – this return 0, HERE IS MY PROBLEM
print(data.rows[tostring(i)].id)
print(data.rows[tostring(i)].name)
print(data.rows[tostring(i)].surname)
print(data.rows[tostring(i)].image_url)
y=y+30;
local text2 = display.newText( data.rows[tostring(i)].id, 0, 0, native.systemFontBold, 18)
text2:setTextColor( 0 )
text2:setReferencePoint( display.CenterReferencePoint )
text2.x, text2.y = display.contentWidth * 0.5, y
group:insert( text2 )
y=y+30;
local text3 = display.newText( data.rows[tostring(i)].name, 0, 0, native.systemFontBold, 18)
text3:setTextColor( 0 )
text3:setReferencePoint( display.CenterReferencePoint )
text3.x, text3.y = display.contentWidth * 0.5, y
group:insert( text3 )
y=y+30;
local text4 = display.newText( data.rows[tostring(i)].surname, 0, 0, native.systemFontBold, 18)
text4:setTextColor( 0 )
text4:setReferencePoint( display.CenterReferencePoint )
text4.x, text4.y = display.contentWidth * 0.5, y
group:insert( text4 )
local function networkListener( event )
if ( event.isError ) then
print ( “Network error - download failed” )
end
end
local img = display.loadRemoteImage(data.rows[tostring(i)].image_url, “GET”, networkListener, “localcopy.jpg”, system.TemporaryDirectory,_W/4,200)
end
else
– prompt them to login again
end
end
return true
end
local URL = “http://www.optisoft.gr/corona/index.php”
network.request( URL, “GET”, loginCallback )
[import]uid: 185094 topic_id: 32109 reply_id: 332109[/import]