MURILLO Posted October 24, 2018 Share Posted October 24, 2018 (edited) Hai, i trying to get all data from a single column, but he get only the first one everytime.I really don't know what to do anymore. Spoiler function getDataFromDB(data) local query = dbQuery(getConnection(), "SELECT * FROM stunts LIMIT 1") local result = dbPoll(query, -1) if (result and #result > 0) then for k, rows in ipairs(result) do return rows[data] end end end addEventHandler("onResourceStart", resourceRoot, function() marker = createMarker(getDataFromDB("x"), getDataFromDB("y"), getDataFromDB("z"), "corona", 1.1, 255, 0, 0, 255) outputChatBox(getDataFromDB("name")) end) Pic from database: Edited October 24, 2018 by MURILLO Link to comment
Dimos7 Posted October 24, 2018 Share Posted October 24, 2018 addEventHandler("onResourceStart", resourceRoot, function() dbQuery(function(queryHandler) local results = dbPoll(queryHandler, 0) for k, row in ipairs(results) do marker = createMarker(row.x, row.y, row.z, "corona", 1.1, 255, 0, 0, 255) end end, getConnection(), "SELECT * FROM stunts LIMIT 1") end) try this 1 Link to comment
MURILLO Posted October 24, 2018 Author Share Posted October 24, 2018 Just now, Dimos7 said: addEventHandler("onResourceStart", resourceRoot, function() dbQuery(function(queryHandler) local results = dbPoll(queryHandler, 0) for k, row in ipairs(results) do marker = createMarker(row.x, row.y, row.z, "corona", 1.1, 255, 0, 0, 255) end end, getConnection(), "SELECT * FROM stunts LIMIT 1") end) try this It worked, thanks. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now