Jump to content

mysql_query problem


UAEpro

Recommended Posts

hello

if i got a table contain 3 rows for example

playername-----Money-----points

UAEpro---------109999-----3124

SoildSnake-------2313-------23

etscfsd----------1234---------43

and i want to get all this value and put it into a gui window

how i can get the values ?

Link to comment
addCommandHandler("get", 
    function () 
        local result = mysql_query(handler, "SELECT * FROM some_table") 
        if (result) then 
            for index, data in ipairs(result) do 
                outputChatBox(data.playername .." - ".. data.Money .." - ".. data.points) 
            end 
            mysql_free_result(result) 
        end 
    end 
) 

Link to comment
addCommandHandler( "get", 
    function ( ) 
        local result = mysql_query( handler, "SELECT * FROM some_table" ) 
        if result then 
            while true do 
                local row = mysql_fetch_assoc( result ) 
                if not row then break end 
                outputChatBox( row.playername .." - ".. row.Money .." - ".. row.points) 
            end 
            mysql_free_result( result ) 
        end 
    end 
) 

Link to comment
addCommandHandler( "get", 
    function ( ) 
        local result = mysql_query( handler, "SELECT * FROM some_table" ) 
        if result then 
            local t = { } 
            while true do 
                local row = mysql_fetch_assoc( result ) 
                if not row then break end 
                table.insert( 
                    t, 
                    { 
                        name = row.playername; 
                        money = row.Money; 
                        points = row.points; 
                    } 
                ) 
            end 
            -- example ------------------------------------------------------------------------ 
            for i = 1,#t do 
                outputChatBox( t[i]['name'] .." - ".. t[i]['money'] .." - ".. t[i]['points'] ) 
            end 
            -------------------------------------------------------------------------------------- 
            mysql_free_result( result ) 
        end 
    end 
) 

You can everything with this table.

table.sort, ...

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...