31.03.2015, 13:48
How would i go about showing all rows in a Mysql database in a dialog.
CMD:results(playerid,params[])
{
mysql_query("SELECT * FROM `table`");
mysql_store_resul();
if(mysql_num_rows())
{
new msg[512];
while(mysql_retrieve_row())
{
new tmp[24],name[24],Float:health,id;
mysql_fetch_field_row(name,"name");
mysql_fetch_field_row(tmp,"health"); health = floatstr(tmp);
mysql_fetch_field_row(tmp,"id"); id = strval(tmp);
format(msg,sizeof(msg),"%s%s - %d - %02f\n",msg,name,id,health);
}
ShowPlayerDialog(playerid,0,DIALOG_STYLE_LIST,"SQL Results",msg,"Close","");
}
else ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"SQL Results","No results found","Close","");
return 1;
}
How would i go about showing all rows in a Mysql database in a dialog.
|
cache_get_data(rows, fields, dbHandle);
BuildingRows = rows;
Building 1 Building 2 Building 3
YCMD:test(playerid, params[], help)
{
#pragma unused params
new str[128];
if(PLogged[playerid] == 0) return
SendClientMessage(playerid, ERROR_COLOR, NOT_LOGGED);
if(PlayerInfo[playerid][pAdmin] < 9 && !IsPlayerAdmin(playerid)) return
SendClientMessage(playerid, COLOR_GREY, ADMIN_CMD_ERROR);
if (help) return
SendClientMessage(playerid, COMMAND_HELP_COLOR, "Test command");
for (new i = 0; i < BuildingRows; i++)
{
printf("Building Rows %d", i+1);
format(str, sizeof(str), "%d %s\n", BuildingInfo[i][buMysqlId],BuildingInfo[i][buName]);
ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"Test",str,"Select","");
}
return 1;
}