Little Help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Little Help (
/showthread.php?tid=554383)
Little Help -
Sanady - 03.01.2015
Hello everybody, today I want to withdraw all names from table that are in squadid 1, well my scheme is:
First I select everything from my table users, then I store that result, after that I check if anything was found if yes then name need to be displayed, now problem is how should display that name? With which function from MySQL?
Re: Little Help -
Sledgehammer - 03.01.2015
so you want to select a few rows out of the database?
SELECT * FROM `Table` WHERE `Field`='Data`
If you want to load the data (if this is what you mean) after you have threaded it, You could do this;
pawn Код:
for(new i=0; i < cache_num_rows(); ++i)
{
//What you want to fetch out of that data.
}
Re: Little Help -
Sanady - 03.01.2015
Quote:
Originally Posted by Death1300
so you want to select a few rows out of the database?
SELECT * FROM `Table` WHERE `Field`='Data`
|
Yes, I know that it`s should be :
SELECT `UserName` FROM `users` WHERE `SquadID` = `1`
And problem is now how should I get that
Username I don`t understand that part
Re: Little Help -
cyberlord - 03.01.2015
you need to store data that u take from database to varable
something like
Код:
PlayerInfo[playerid][Name] = cache_get_field_content_string(0, "Username");
so you can use them in future like
Printf("PlayerInfo[playerid][Name]");
Re: Little Help -
Sledgehammer - 03.01.2015
What mySQL version are you using?
Re: Little Help -
Sanady - 03.01.2015
Quote:
Originally Posted by cyberlord
you need to store data that u take from database to varable
something like
Код:
PlayerInfo[playerid][Name] = cache_get_field_content_int(0, "Username");
|
Well I am using R6
Quote:
Originally Posted by Death1300
What mySQL version are you using?
|
I am using R6
Re: Little Help -
cyberlord - 03.01.2015
Quote:
Originally Posted by Sanady
Well I am using R6
I am using R6
|
why dont u want to update to r39 ?
Re: Little Help -
Sledgehammer - 03.01.2015
Ok. Since your not threading quires, You should load your data to something alike this:
pawn Код:
new username[MAX_PLAYER_NAME+1];
mysql_query("SELECT `UserName` FROM `users` WHERE `SquadID` = `1`");
mysql_store_result();
while(mysql_retrieve_row())
{
mysql_fetch_field_row(username, "Username");
// etc..
}
mysql_free_result();
https://sampwiki.blast.hk/wiki/MySQL - More information.
Re: Little Help -
Sanady - 03.01.2015
Quote:
Originally Posted by Death1300
Ok. Since your not threading quires, You should load your data to something alike this:
pawn Код:
new username[MAX_PLAYER_NAME+1];
mysql_query("SELECT `UserName` FROM `users` WHERE `SquadID` = `1`"); mysql_store_result(); while(mysql_retrieve_row()) { mysql_fetch_field_row(username, "Username"); // etc.. } mysql_free_result();
https://sampwiki.blast.hk/wiki/MySQL - More information.
|
YES thanks reputation!
Re: Little Help -
Sanady - 03.01.2015
Quote:
Originally Posted by Death1300
Ok. Since your not threading quires, You should load your data to something alike this:
pawn Код:
new username[MAX_PLAYER_NAME+1];
mysql_query("SELECT `UserName` FROM `users` WHERE `SquadID` = `1`"); mysql_store_result(); while(mysql_retrieve_row()) { mysql_fetch_field_row(username, "Username"); // etc.. } mysql_free_result();
https://sampwiki.blast.hk/wiki/MySQL - More information.
|
Well I tried that and it`s not working