Posts: 3,004
Threads: 12
Joined: May 2011
Although I recommend phpMyAdmin to browse the MySQL database (while on development, having it hosted on production can be a security risk, once (& if) breached
PHP код:
forward OnHouseStripHouseData(playerid);
public OnPlayerConnect(playerid) {
new query[512];
GetPlayerName(playerid, pname, sizeof(pname));
mysql_format(mysql, query, sizeof(query),"SELECT `ID`,`Model` FROM `furniture` WHERE `MasterID`=%i",AccInfo[playerid][HouseOwner]);
mysql_tquery(mysql, query, "OnHouseStripHouseData");
return 1;
}
public OnHouseStripHouseData() {
new
dest[128], // we will store the field data here
rows=cache_num_rows(), // get number of rows in the result
fields=cache_get_field_count(); // get the number of fields in the result
// Loop through all the existing rows in the result
for(new x=0;x<rows;x++) {
// Loop through all the fields on the specific row
for(new y=0;y<fields;y++) {
// Get data from row X and field number Y from left to right
cache_get_row(x, y, dest);
// Print it !
printf("| %s", dest);
}
}
return 1;
}
inb4, untested.
Don't have anything to test with, its improvised.
Posts: 3,004
Threads: 12
Joined: May 2011
use
strcat to push each field to the array, after the field loop ends (which means - end of row) print the array.
Posts: 803
Threads: 138
Joined: Jul 2014
Reputation:
0
Ah, mind just showing me how? I know what you mean but im not sure how to push them multiple into 1 line
Posts: 2,593
Threads: 34
Joined: Dec 2007
pawn Код:
forward OnHouseStripHouseData();
public OnHouseStripHouseData()
{
new id,model,rows = cache_num_rows(); // get number of rows in the result
for(new i=0; i < rows; i++)
{
id = cache_get_field_content_int(i, "ID");
model = cache_get_field_content_int(i, "Model");
printf("%d|%d", id, model);
}
return 1;
}
Posts: 803
Threads: 138
Joined: Jul 2014
Reputation:
0
There is 1 problem, it sorta creates an infinite loop. It keeps telling all players the furniture ID after they buy one afterwards.