Raised This Month: $ Target: $400
 0% 

saving via sql


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 04-18-2011 , 14:32   saving via sql
Reply With Quote #1

i have something like this

PHP Code:
enum _:ilist
{
    
list1,
    
list2,
    
list3
};

new const 
gListnameilist ][ ] =
{
    
"list1",
    
"list2",
    
"list3"
};

new 
gPlayerListData33 ][ ilist ]; 
i was wondering how to save all the data into a sql table with an loop ?
on webpage should be something like

"list name 1" "player data for listname1"

etc
__________________
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-18-2011 , 21:24   Re: saving via sql
Reply With Quote #2

You would need a table like this:
- listname VARCHAR(10) NOT NULL (change 10 to however long you may need the name)
- listdata INT(11) NOT NULL (assumed an int based on the global variable)
- authid VARCHAR(35) NOT NULL
- PRIMARY KEY(listname, authid)

Then you can do this:
Code:
new szAuthID[ 35 ]; get_user_authid( iPlayer, szAuthID, charsmax( szAuthID ) ); new Handle:hQuery; for( new i; i < ilist; i++ ) {     hQuery = SQL_PrepareQuery( /* connection */,\         "INSERT INTO table \         (listname, listdata, authid) \         VALUES \         (^"%s^", %d, ^"%s^") \         ON DUPLICATE KEY UPDATE \         listdata = %d;",\         gListname[ i ], gPlayerListData[ iPlayer ][ i ], szAuthID, gPlayerListData[ iPlayer ][ i ] );         // execute query }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 04-19-2011 at 05:31.
Exolent[jNr] is offline
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 04-19-2011 , 05:22   Re: saving via sql
Reply With Quote #3

i was expecting to you to answer, thanks


since i suck on sql, how to retrieve the data with this way?
__________________

Last edited by tuty; 04-19-2011 at 05:41.
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-20-2011 , 14:19   Re: saving via sql
Reply With Quote #4

You can use a trie to save the list name associated to its constant.

Then when you load data from the player, check the list name to the constant using the trie, then save the listdata from the table into the array.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



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 19:47.


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