mysql save
#1

Hi,

What best way, for example i want to create all days players how much they have score, so i will have to everyday use 'insert into' doing cikle all my players in database and create? for ex:

Code:
/myscore [2016-09-05]
/myscore [2016-09-04]
Reply
#2

It's hard to understand what you're trying to say, but from what I gather you are looking to know how to store the date and score into MySQL using "INSERT INTO"?

PHP Code:
new yearmonthday;
getdate(yearmonthday);
new 
date[16];
format(datesizeof(date), "[%i-%i-%i]"yearmonthday);
new 
name[MAX_PLAYER_NAME];
GetPlayerName(playeridnameMAX_PLAYER_NAME);
new 
query[256];
mysql_format(connectionHandlequerysizeof(query), "INSERT INTO `playerscores` (`PlayerName`, `Score`, `Date`) VALUES (`%s`, `%i`, `%s`);"name,  GetPlayerScore(playerid), date);
mysql_query(connectionHandlequery); 
Reply
#3

Yea. But imaginage i have 10000 players in database, i have to use insert into 10000 times? everytime on new day?
Reply
#4

Do you want to UPDATE the player's score every day or store the score separately using INSERT? If you want to replace the existing score, then you'd do something like:

PHP Code:
new query[256], name[MAX_PLAYER_NAME];
GetPlayerName(playeridnameMAX_PLAYER_NAME);
mysql_format(connectionHandlequerysizeof(query), "UPDATE `playerscores` SET `Score` = %i WHERE `PlayerName` = %s"GetPlayerScore(playerid), name); 
mysql_query(connectionHandlequery); 
Reply
#5

I don't think you are explaining this at all clear enough, and there'll be a better way to handle this.
Reply
#6

I don't know what you don't understand.. Like i want to make log, player can view. Every day log.
Reply
#7

You could do that by making the log, each time they play, not every day process 10000 dormant accounts...
Reply
#8

Yes, but how to save information how create that rows, tables. I know like make log last top20, but if there is thousands? ok i create variable

#define MAX_LOGS 1500
#define MAX_LOG_LENGHT 100
new LOGS[ MAX_PLAYERS ][ MAX_LOGS ][ MAX_LOG_LENGHT ];


So i need to save that variable all 1500, can i create that many rows?
Reply
#9

Yes you can create that many rows, that is what SQL is for.

Creating variables though is not what you need. You can simply write the info directly to the DB...

You'd only create the variables if you were actually storing it all, in the script itself.
Reply
#10

Yes, but in command everytime call database i think it can harm server
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)