PHP user image table help?

Well, I have absolutely no idea what to call this, so the subject is just a load of words I threw together at random… :stuck_out_tongue:

Anyway, I need some help with this, I’m new to PHP and it can get complicating.

First things first, I own a game server, I’m using a plugin on this server to write information about a player to a database. I’ve created a PHP file that pulls this information from the database and writes it neatly in to a table. That much is simple, this next bit isn’t so much.

The first column of the table is where the usernames of the players are pulled from the database and placed in to a row. But before the usernames, I want to pull an image of the player from a different location and have it in the same row.

The bit I can’t work out is, how do I get the username of each row, place it at the end of a img link and then have that written in to a table?

A link to the working PHP site: http://75.127.4.114/mybb/playerstats.php

Here’s my PHP file for the table:
[php]

<?php $con=mysqli_connect("localhost","user","pass","db"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); }

$result = mysqli_query($con,“SELECT * FROM stattracker”);

echo "

";

while($row = mysqli_fetch_array($result))
{
echo “

”;
echo “”;
echo “”;
echo “”;
echo “”;
echo “”;
echo “”;
echo “”;
echo “”;
echo “”;
}
echo “
Minecraft Name Kills Deaths Mob Kills XP Level Blocks Placed Blocks Broken Last Seen
” . $row[‘username’] . “” . $row[‘pvp’] . “” . $row[‘death’] . “” . $row[‘pve’] . “” . $row[‘xp’] . “” . $row[‘blocksplaced’] . “” . $row[‘blocksbroken’] . “” . $row[‘lastseen’] . “
”;

mysqli_close($con);
?>

[/php]

And here’s the link I want to pull the images from: <img src="https://minotar.net/avatar/"username goes here"/10.png">

Any help will be appreciated. :slight_smile:
Regards,

This is the image tag (path needs adjusting to suit your needs)
[php]<?= $row['username']; ?>[/php]

Pop it into your script like so:
[php]
while($row = mysqli_fetch_array($result))
{
$user_image = ‘' . $row['username'] . '’;
echo “

”;
echo “” . $user_image . “”;
echo “” . $row[‘username’] . “”;
echo “” . $row[‘pvp’] . “”;
[/php]

Hope that helps,
Red :wink:

Edit: don’t forget to change the .jpg to .jpg|.bmp|.png or whatever file extension you use :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service