Basically, I'm making a table that outputs people that have been banned. So far, I have everything done with MySQLi, just instead of showing the actual name it shows the player ID. I'm having trouble with this because the players ID is stored in a seperate table.
http://i.stack.imgur.com/sy6G9.png
This picture is the structure of the main table, notice player_id and creator_id? What I have to do is match the ID and replace the number with the row "name" accordingly from the other table shown below http://i.stack.imgur.com/Lm3Fg.png
If you could help me out, I'd appreciate it greatly.
This query will just show you the names of the banned players:
SELECT name FROM banned_table INNER JOIN name_table ON player_id=name_table.id
Of course you would need to change banned_table
and name_table
to the actual tablenames in your DB.
UPDATE: From the comments below this is the solution for the OP
SELECT b.*,n.name as player, n2.name as admin FROM banhammer_bans b
JOIN name_table n ON b.player_id=n.id
JOIN name_table n2 ON b.creator_id=n2.id
ORDER BY b.created_at DESC
And change the display code:
echo'<td>' . $row['player_id'] . '</td>';
echo'<td>' . $row['creator_id'] . '</td>';
To Be:
echo'<td>' . $row['player'] . '</td>';
echo'<td>' . $row['admin'] . '</td>';
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments