• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Gesior: get char name by id

raf

Active Member
Joined
Jan 10, 2011
Messages
261
Reaction score
38
Location
Warsaw, PL
How can i get character name by id ?
i have query to get latest news posts from forum:
PHP:
$query = $SQL->query("SELECT `z_forum`.`icon_id`,`z_forum`.`post_topic`, `z_forum`.`author_guid`, `z_forum`.`post_date`, `z_forum`.`post_text`, `z_forum`.`id`, `z_forum`.`replies`, `players`.`name` FROM `z_forum`, `players` WHERE `section` = '1' AND `z_forum`.`id` = `first_post` AND `players`.`id` = `z_forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 6;")->fetchAll();

PHP:
$author_guid
is the id of author

i've been already looking into forum.php file to check how it's done in there, but can't reproduce it in latestnews.php ;s
 
Last edited:
How can i get character name by id ?
i have query to get latest news posts from forum:
PHP:
$query = $SQL->query("SELECT `z_forum`.`icon_id`,`z_forum`.`post_topic`, `z_forum`.`author_guid`, `z_forum`.`post_date`, `z_forum`.`post_text`, `z_forum`.`id`, `z_forum`.`replies`, `players`.`name` FROM `z_forum`, `players` WHERE `section` = '1' AND `z_forum`.`id` = `first_post` AND `players`.`id` = `z_forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 6;")->fetchAll();

PHP:
$author_guid
is the id of author

i've been already looking into forum.php file to check how it's done in there, but can't reproduce it in latestnews.php ;s

Code:
`players`.`id` = `z_forum`.`author_guid`

So...
PHP:
$author_guid
is literally just the playerid.

This should work:
PHP:
$query = $SQL->query('SELECT `name` from `players` where `id` = '.$author_guid.';')->fetch();
 
Last edited:
How can i get character name by id ?
i have query to get latest news posts from forum:
PHP:
$query = $SQL->query("SELECT `z_forum`.`icon_id`,`z_forum`.`post_topic`, `z_forum`.`author_guid`, `z_forum`.`post_date`, `z_forum`.`post_text`, `z_forum`.`id`, `z_forum`.`replies`, `players`.`name` FROM `z_forum`, `players` WHERE `section` = '1' AND `z_forum`.`id` = `first_post` AND `players`.`id` = `z_forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 6;")->fetchAll();

PHP:
$author_guid
is the id of author

i've been already looking into forum.php file to check how it's done in there, but can't reproduce it in latestnews.php ;s
It already gets name of players by SELECT ... , `players`.`name` FROM ...

So to display name of player (it's list of topics, so to display anything you must iterate over it 'foreach'):
PHP:
$query = $SQL->query("SELECT `z_forum`.`icon_id`,`z_forum`.`post_topic`, `z_forum`.`author_guid`, `z_forum`.`post_date`, `z_forum`.`post_text`, `z_forum`.`id`, `z_forum`.`replies`, `players`.`name` FROM `z_forum`, `players` WHERE `section` = '1' AND `z_forum`.`id` = `first_post` AND `players`.`id` = `z_forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 6;")->fetchAll();
foreach($query as $thread)
{
     echo 'Thread author character name: ' . $thread['name'];
}
Of course it's not nice that it gets name of player from variable $thread['name'], but this is how works that simple forum [1 table forum].
 
Hey, i'm back to this issue. I've made a script that stores player id in database instead of name ( i don't know how to store correctly name ), and i want to pull it out on website as player name. Is there a function for that ?

Nevermind...
Figured it out my self :)
PHP:
db.escapeString(Player_name)
in sql query to insert data, and then i can pull the name from database
 
Last edited:
Back
Top