Admigo|clan1 Test1|clan1 Test2|clan2 Test3|clan2 Test4|clan1
SELECT COUNT(*)
FROM clan_members
WHERE clanid = %d
GROUP BY clanid
try this:
SELECT COUNT(*) AS `CLANTOTAL` FROM TABLE WHERE CLAN = CLANNAME later.. mysql_fetch_field_row(clanCount,"CLANTOTAL"); now u have ur value in clanCount. (sorry for bump , i just noticed it while scrolling through forum) |
PlayerName|ClanName Admigo|Clan1 Test1|clan2 Test2|Clan1
Admigo Test2
SELECT playername FROM clan_members WHERE clanname = 'blah'
This is pretty much the simples of SQL queries that exist. I suggest you read up on SQL some more.
PHP код:
|
case _THREAD_GET_CLAN_MEMBERS :
{
new resultline[512];
mysql_store_result();
if(mysql_num_rows(gSQL) > 0)
{
while(mysql_fetch_row_format(resultline,"|"))
{
mysql_fetch_field_row(resultline,"playername");
printf("%s\n",resultline);
}
}
mysql_free_result();
}
Can you provide relevant table and column names? It's not clear to me whether you're storing the data in one or multiple tables.
|
stock GetClanMembers(clan[])
{
new clanquery[200];
format(clanquery, sizeof(clanquery), "SELECT * FROM a_clans_members WHERE clanname = '%s'", clan);
mysql_query(clanquery, _THREAD_GET_CLAN_MEMBERS, -1, gSQL);
return 1;
}
clanname|playername
15:29:29] >> mysql_query_callback(Connection handle: 1)
[15:29:29] ProcessQueryThread(OnQueryFinish) - Executing query SELECT * FROM a_clans_members WHERE clanname = 'acnr'...
[15:29:29] ProcessQueryThread(OnQueryFinish) - Query was successful.
[15:29:29] ProcessQueryThread(OnQueryFinish) - Data being passed to ProcessTick().
[15:29:29] OnQueryFinish(siii) - Callback is being called...
[15:29:29] >> mysql_store_result(Connection handle: 1)
[15:29:29] CMySQLHandler::StoreResult() - Result was stored.
[15:29:29] >> mysql_num_rows(Connection handle: 1)
[15:29:29] CMySQLHandler::NumRows() - Returned 2 row(s).
[15:29:29] >> mysql_fetch_row_format(Connection handle: 1)
[15:29:29] CMySQLHandler::FetchRow() - Return: 7|acnr|Admigo|10|1|1.
[15:29:29] >> mysql_fetch_field_row(Connection handle: 1)
[15:29:29] CMySQLHandler::FetchField(playername) - You cannot call this function now (no result).
[15:29:29] >> mysql_fetch_row_format(Connection handle: 1)
[15:29:29] CMySQLHandler::FetchRow() - Return: 7|acnr|Andy|1|1|2.
[15:29:29] >> mysql_fetch_field_row(Connection handle: 1)
[15:29:29] CMySQLHandler::FetchField(playername) - You cannot call this function now (no result).
[15:29:29] >> mysql_fetch_row_format(Connection handle: 1)
[15:29:29] >> mysql_free_result(Connection handle: 1)
[15:29:29] CMySQLHandler::FreeResult() - Result was successfully freed.