for(new i = 0; i < 10; i++) {
Player[playerid][playerPmBlocks][i] = 0;
valstr(temp, Player[playerid][playerPmBlocks][i]);
strcat(blockstring, temp, sizeof(blockstring));
strcat(blockstring, ",", sizeof(blockstring));
}
enum PlayerInfo {
playerPmBlocks[255]
};
new Player[MAX_PLAYERS][PlayerInfo];
cache_get_value(0, "ppmblocks", tempblocks, 255);
Also, I am highly unsatisfied by this code. If you guys have any better way to do this, please let me know.
|
I want to store multiple values in one field in the MySQL database.
This is the way I am currently using to store data (convert to string and concatenate a comma) PHP код:
PHP код:
PHP код:
Also, I am highly unsatisfied by this code. If you guys have any better way to do this, please let me know. This is an urgency. |
Glad you are because storing multiple values into a single column is the wrong way to go. What you need is another table.
|
I want to store multiple values in one field in the MySQL database.
This is the way I am currently using to store data (convert to string and concatenate a comma) PHP код:
PHP код:
PHP код:
Also, I am highly unsatisfied by this code. If you guys have any better way to do this, please let me know. This is an urgency. |
/* > tempblocks is your string tight ? with 255 Char size*/
new tempblocks[255]; // Defined Like This Means can store 255 chars
new tempchar = 0;
new tempstring[128];
new temparrycount = 0;
cache_get_value(0,"ppmblocks",tempblocks,255);
for(new i=0;i<sizeof(tempblocks),i++)
{
tempchar = strfind(tempblocks,",",true); // tempchar now will have position of that , char in string
strmid(tempstring,tempblocks,0,(tempchar-1); // now we have first string before , in tempstring
playerPmBlocks[playerid][temparrycount] = strval(tempstring); // use strval if its a number which storing in
temparrycount++;
//Now we have to Delete the part we extracted
strdel(tempblocks,0,tempchar);
if(strfind(tempblocks,",",true) == -1) { // lets check if all comos removed so get the last string which is left
playerPmBlocks[playerid][temparrycount] = strval(tempblocks);
break;
}
}
Glad you are because storing multiple values into a single column is the wrong way to go. What you need is another table.
|