a little question with mysql. - 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: a little question with mysql. (
/showthread.php?tid=323866)
a little question with mysql. -
EviLpRo - 07.03.2012
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.
Re: a little question with mysql. -
Shabi RoxX - 07.03.2012
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
Re: a little question with mysql. -
EviLpRo - 07.03.2012
you dont understend..
i want to do that select a multi field in one query.
Re: a little question with mysql. -
EviLpRo - 08.03.2012
bump.
please help..
Re: a little question with mysql. -
Sinner - 08.03.2012
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