Raised This Month: $ Target: $400
 0% 

Sql update player choosing


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
spirit
Senior Member
Join Date: Jul 2009
Location: Quimper
Old 07-11-2012 , 03:53   Sql update player choosing
Reply With Quote #1

Hi all,

I trying to made a simple menu with all name for all player who has the same item on my db.

it's my request sql "SELECT `name` FROM `xprpg_data` WHERE `item` = %d"

But on my function 'submenuitem(id, menu, item)'. How i can take the name on the line choosing for remove this item ( UPDATE `xprpg_data` SET `item` = '0' WHERE `name` = %s )

(resume: create menu with all player who has item = on the player who open menu and choosing player for remove this item).

PHP Code:
public Remove_Item(id)
{
    new 
Data[1]
    
Data[0] = id
    
new szTemp[512]
    
format(szTemp,charsmax(szTemp), "SELECT `name` FROM `xprpg_data` WHERE `item` = %d"HasItem[id])
    
SQL_ThreadQuery(g_SqlTuple,"Sql_List",szTemp,Data,1)

    return 
PLUGIN_CONTINUE;
}

public 
Sql_List(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
        
log_amx("Load - Could not connect to SQL database.  [%d] %s"ErrcodeError);
    else if(
FailState == TQUERY_QUERY_FAILED)
        
log_amx("Load Query failed. [%d] %s"ErrcodeError);
  
    new 
id Data[0]
    
    new 
name[32]
    new 
menu menu_create("Choose player""submenuitem")
    
    while(
SQL_MoreResults(Query))
    {
        
SQL_ReadResult(Query0namecharsmax(name))
        
menu_additem(menu"\w%s"name
        
SQL_NextRow(Query)
    } 
    
menu_display(idmenu0)
    return 
PLUGIN_HANDLED
}  

public 
submenuitem(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED;
        
// ???
    
}
    

spirit is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode