a little question with mysql.
#1

hello pepole.

i have a small question.
how i select a one more field from the table?

this my start code:

pawn Код:
mysql_query("SELECT `Kills`,`Level` FROM `users`");
new kills,level;
i want that var kills equal to `Kills` field and var level equal to `Level` field.

thank's a lot.
Reply
#2

To Select one more:

pawn Код:
mysql_query("SELECT `Kills`,`Level`,`row3name` FROM `users`"); // just add ,`xxx` like this
TO select all fields do this.
pawn Код:
mysql_query("SELECT * FROM `users`"); // * goes for all
Reply
#3

you dont understend..
i want to do that select a multi field in one query.
Reply
#4

bump.
please help..
Reply
#5

To LOAD them from the database:

pawn Код:
new kills, level;
mysql_query("SELECT * FROM `users`");
mysql_store_result();
if(mysql_retrieve_row()) {
    new tmp[2][9];
    mysql_get_field("Kills", tmp[0]);
    mysql_get_field("Level", tmp[1]);
    kills = strval(tmp[0]);
    level = strval(tmp[1]);
}
mysql_free_result();
// kills will now contain the value of 'Kills' in the database, same for Level
To SAVE them to the database:

pawn Код:
new query[128];
format(query, sizeof(query), "UPDATE `users` SET `Kills` = %d, `Level` = %d", kills, level);
mysql_query(query);
Hope that helped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)