Read from Mysql?
#1

Hello,today i was trying to create a command /banlist for my server,that will get all the names from the table "bans" and row "name" and will show me banned players.I dont know much on mysql and i need your help....

I will show you the line i use to store bans on database,maybe that will make it easier :

Код:
format(q, sizeof(q), "INSERT INTO bans (id, name, reason, ban_time, issue_time, expiry_time, admin, ip) VALUES ('', '%s', '%s', %d, %d, %d, '%s', '%s')", namegive, reason, time, curtime, expire, name, ip);
	mysql_query(q, THREAD_INSERT_BAN);
Thank you!
Reply
#2

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
Giving you a query right now will not teach you anything.
****** and read! http://www.w3schools.com/sql/
Still can not get it to work....!I know it needs to be done something like:
Код:
format(str,sizeof(str),"SELECT 'Name' FROM bans .......;
But it does not work!
Anyone can help,because i need it right know.I dont have time to learn all mysql
Reply
#3

Without apostrophes around the name of the column because that makes it as a literal text and will retrieve "Name" instead of the data you want to.
Reply
#4

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Without apostrophes around the name of the column because that makes it as a literal text and will retrieve "Name" instead of the data you want to.
Yeah,but i dont know how to store it to the mysql result and then use it as a string so it will show me all names...
Reply
#5

https://sampwiki.blast.hk/wiki/MySQL/R40#mysql_format

you can create queries with that, it is like string format
Reply
#6

1) Loop from 0 to rows-1
2) cache_get_value (R40+) or cache_get_row/cache_get_field_content (R33 to R39-6) function inside the loop to retrieve the data, where rowid = iteration variable
3) re-format or format + strcat to "join" the text with the rest
Reply
#7

I can not get it to work.Im really bad on this mysql sh*t.Thanks anyway....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)