Little Help
#1

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?
Reply
#2

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.
}
Reply
#3

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
Reply
#4

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]");
Reply
#5

What mySQL version are you using?
Reply
#6

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
Reply
#7

Quote:
Originally Posted by Sanady
Посмотреть сообщение
Well I am using R6



I am using R6
why dont u want to update to r39 ?
Reply
#8

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.
Reply
#9

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!
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)