Also normally after you do a database query, you’re given a “result” set, not individual items. Your query can typically return multiple rows with multiple data fields. Normally there is a while loop and a command to fetch a row from the result set that returns an associative array. Then you can take the table of data to access individual fields.
It’s going to be hard to be more specific without knowing the scheme of your database tables.
You access the script with the network.request() API call. You give it the URL of your script, pass any HTTP GET or POST data items. Then when the script completes, your network.request()'s call back function will be called with the output of the script. It’s recommended that you use output your data in JSON format then when you get it back in the script, use the built in json.decode() function to turn the script output into a Lua table.
local function networkListener( event ) if ( event.isError ) then print( "Network error: ", event.response ) else print ( event.response ) end end network.request( "YOUR\_SERVER", "GET", networkListener )
Also normally after you do a database query, you’re given a “result” set, not individual items. Your query can typically return multiple rows with multiple data fields. Normally there is a while loop and a command to fetch a row from the result set that returns an associative array. Then you can take the table of data to access individual fields.
It’s going to be hard to be more specific without knowing the scheme of your database tables.
You access the script with the network.request() API call. You give it the URL of your script, pass any HTTP GET or POST data items. Then when the script completes, your network.request()'s call back function will be called with the output of the script. It’s recommended that you use output your data in JSON format then when you get it back in the script, use the built in json.decode() function to turn the script output into a Lua table.
local function networkListener( event ) if ( event.isError ) then print( "Network error: ", event.response ) else print ( event.response ) end end network.request( "YOUR\_SERVER", "GET", networkListener )