Hey
i really need help!! I got a MySQL database and want to get the output into the Tableview but it does´t work. It is very urgent that I solve this problem so here my script:
The Response i get from my database response is something like this:
RESPONSE: {“result”:200,“message”:“Success”,“entry count”:3,“entry_366”:{“id”:“366”,“name”:“Testeintrag Abnahme”,“street”:“Keine Strasse 20”,“zip”:“123456”,“city”:“City”},“entry_367”:{“id”:“367”,“name”:“Testeintrag Abnahme”,“street”:“Keine Strasse 20”,“zip”:“123456”,“city”:“City”},“entry_368”:{“id”:“368”,“name”:“Testeintrag Abnahme”,“street”:“Keine Strasse 20”,“zip”:“123456”,“city”:“City”}}
My Lua Skript looks like this:
[lua] local tableView = require(“tableView”)
local mime = require( “mime” )
local json = require(“json”)
local data {}
local jSon_result, myList
local function networkListener( event )
if ( event.isError ) then
print( “Network error!”)
else
print ( "RESPONSE: " … event.response )
jSon_result = json.decode(event.response)
for i=366, 366+jSon_result.entrycount do
data[i] = {}
data[i].title = jSon_result.entry_(i).name
data[i].subtitle = jSon_result.entry_(i).street
print ( jSon_result.entrycount )
–table.insert(data, data[i])
end
end
end
responseJSon = network.request( “http://…”, “GET”, networkListener )
– Create a list with no background, allowing the background image to show through
myList = tableView.newList{
data=data,
default=“grafik/menue/liste.png”,
top=topBoundary,
bottom=bottomBoundary,
callback=function(row)
local g = display.newGroup()
local title = display.newText(row.title, 0, 0, native.systemFontBold, 36)
g:insert(title)
title:setTextColor(0, 0, 0)
title.x = math.floor(title.width/2) + 175
title.y = 35
local subtitle = display.newText( row.subtitle, 0, 0, native.systemFont, 24 )
g:insert(subtitle)
subtitle:setTextColor(102,102,102)
subtitle.x = math.floor(subtitle.width/2) + 175
subtitle.y = 70
return g
end
}[/lua]
I will be very pleased if you could help me i get no error in the terminal but it doesn´t work and I haven´t got many time to make it.
THANK YOU!!! [import]uid: 149464 topic_id: 27499 reply_id: 327499[/import]