Jump to content

mysql_query problem


UAEpro

Recommended Posts

Posted

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 ?

تيم سبيك بروجيمر

ts3server://ts.pg.sa

Posted
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 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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 
) 

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

My code would have worked with the new DB functions, I have never used Ryden's module.

Edit:

table.insert(_top,{row.name,row.Money,row.point}) -- You forgot a comma after row.Money. 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

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