Jump to content

Question for SQL


xFFrozen

Recommended Posts

Hey 

I have a Code, which search SQL Database for a result..
Everything works fine, but it only finde ONE result.. What can I do, to have more than one result?

 

My Code:

	for i=1,8 do
		local f=dbPoll(dbQuery(handler,"SELECT `Name` FROM `userdata` WHERE Test1 = ? AND Test2 = ?","5",tostring(i)),-1,true)
		local f=f[1]
		if f then
			for k,v in pairs (f) do
				outputChatBox(v..' TEstTEst ')
			end
		end
	end

 

Link to comment

Read the wiki page for dbPoll, there's a ton of examples displaying how to fetch results correctly.

connection = dbConnect("sqlite", "test.db")
queryhandle = dbQuery( connection, 'SELECT * FROM Test1')
result = dbPoll(queryhandle, -1)
	
for rid, row in ipairs (result) do -- row represents the tables that are in 'result', which represent the rows
    for column, value in pairs (row) do -- column represents column name, value represents column value
        outputChatBox(column..', '..value)
    end
end

 

Edited by Skully
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...