new query[512];
mysql_format(mysql, query, sizeof(query),"SELECT `ID`,`Model` FROM `furniture` WHERE `MasterID`=%i",AccInfo[playerid][HouseOwner]);
mysql_tquery(mysql, query);
print(query);
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;
}
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 код:
Don't have anything to test with, its improvised. |
YCMD:test(playerid,params[],help) {
new query[512];
mysql_format(mysql, query, sizeof(query),"SELECT `ID`,`Model` FROM `furniture` WHERE `MasterID`=%i",AccInfo[playerid][HouseOwner]);
mysql_tquery(mysql, query, "OnHouseStripHouseData");
return true;
}
forward OnHouseStripHouseData(playerid);
public OnHouseStripHouseData(playerid) {
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
for(new x=0;x<rows;x++) {
for(new y=0;y<fields;y++) {
cache_get_row(x, y, dest);
printf("| %s", dest);
}
}
return 1;
}
[20:09:15] | 6
[20:09:15] | 2290
[20:09:15] | 7
[20:09:15] | 2290
[20:09:15] | 8
[20:09:15] | 2290
[20:09:15] | 9
[20:09:15] | 2290
[20:09:15] | 10
[20:09:15] | 2290
[20:09:15] | 11
[20:09:15] | 2290
[20:09:15] | 12
[20:09:15] | 2290
Ah, mind just showing me how? I know what you mean but im not sure how to push them multiple into 1 line |
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;
}
pawn Код:
|