Priting Fields From Mysql
#1

How would i print a single field from a table in to a string you know the
pawn Код:
%s
Example:

I have a table called players and in that table i have a field called PlayerNames

What i wanna do is print all the rows with just the PlayerNames

I have 5 rows each have diffrent names.

I wanna print all the names in to one string.

I'm using striken kids plugin
Reply
#2

pawn Код:
new rQuery[ 50 ];
mysql_query( "SELECT `playerName` FROM `players`" );
mysql_store_result( );
while( mysql_fetch_row_format( rQuery, "|" ) )
{
//Store playername
}
Reply
#3

There isn't a
pawn Код:
mysql_fetch_row_format( rQuery, "|" )
In stricken kids Mysql Plugin.
Reply
#4

Just try this for stricken kids:
pawn Код:
mysql_fetch_row(rQuery);
Because "|" is already set by default in the function
See:
native mysql_fetch_row(dest[], const splitter[] = "|", MySQL:handle = MySQL:0);
Reply
#5

It's only printing the first name in the table. I want it to print all the names

pawn Код:
new rQuery[ 50 ];
            mysql_query( "SELECT PlayersName FROM warrants" );
            mysql_store_result( );
            mysql_fetch_row(rQuery);
            format(str, sizeof (str), "%s\n",Warrants[wPname]);
I'm trying to make it where you can get all warrants in the warrant database, So cops can go through and take care of the warrants in game.
Reply
#6

Lemme Clarify myself

Ok, i have been trying to make a warrant system for cops which is mysql. I got it to insert just fine. But when i go to the dialog to check the warrants, It only prints 1 name or no names.

Baically i want a dialog to show all the names in the database of players who have warrants.

How would i get it to print all the names in the warrants table under field PlayersName.

My enum

pawn Код:
enum wWarrants
{
    wPId,
    wPname[24],
    wWantedFor[64],
    wGivenBy[24],
    wStatus[64]
};
new Warrants[MAX_PLAYERS][wWarrants];
The code that suppose to shwo all the names

pawn Код:
format(Query, sizeof (Query), "SELECT PlayersName FROM warrants");
            mysql_query(Query);
            mysql_store_result( );
            printf("%s",Query);
            format(str, sizeof (str), "%s\n",Warrants[WarrantCount][wPname]);
            switch(listitem)
            {
        case 0: ShowPlayerDialog(playerid, 38, DIALOG_STYLE_LIST, "Open Warrants", str, "Get Info", "Cancel");
I know i got somthing wrong but i can't figure it out.


WarrantCount comes from this
pawn Код:
stock LoadMysqlWarrants()
{
    format(Query, sizeof(Query), "SELECT * FROM warrants");
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(Query))
        {
            sscanf(Query, "e<p<|>ds[24]s[64]s[24]s[64]>", Warrants [ WarrantCount ]);
            printf("%s",Query);
            printf(" Warrants Id: %s",Warrants[WarrantCount][wPId]);
            printf(" Warrants Name: %s",Warrants[WarrantCount][wPname]);
            printf("Wanted For: %s",Warrants[WarrantCount][wWantedFor]);
            printf("GivenBy: %s",Warrants[WarrantCount][wGivenBy]);
            printf("Status: %s",Warrants[WarrantCount][wStatus]);
            WarrantCount++;
        }
    }
    mysql_free_result();
    printf("%d Warrants('s) Loaded From Mysql DataBase", WarrantCount);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)