PHP-图像播种重叠查询结果



我想知道是否有人可以帮助我使用这件代码?它的设计目的是将数据提取数据,然后将所述数据放入图像中。但是,我遇到了一个问题,即查询的所有行都在彼此的顶部打印出来,而不是每次新线!我敢肯定,这是我忽略的简单的事情,但是任何帮助都将不胜感激!也很抱歉,它正在建设中,看起来不整洁!因此,可以明确的是,我正在寻找它可以循环遍历所有行,并将它们显示在垂直列表中,但是,它目前正在彼此显示它们都没有任何线路!

<?php
$config = parse_ini_file('inc/config.ini'); 
$config1["image"] = "images/back.jpg"; // The default background image
// Try and connect to the database
$connection = mysqli_connect('127.0.0.1:3312',$config['username'],$config['password'],$config['dbname']);
// If connection was not successful, handle the error
if($connection === false) {
    // Handle error - notify administrator, log to a file, show an error screen, etc.
}
$result = mysqli_query($connection, "SELECT Name,PvPKills,PvEKills,NPCKills,HeliKills,APCKills,Deaths,Suicides,Status,TimePlayed FROM playerranksdb ORDER BY PvPKills DESC, PvEKills DESC, NPCKills DESC, HeliKills DESC, APCKills DESC LIMIT 10")
or die(mysqli_error()); 
// Make the image
        header ('Content-type: image/png');
        if(!isset($_GET['style'])) {
        $im = imagecreatefromjpeg($config1["image"]); } else {
        $im = imagecreatefromjpeg("image".$_GET['style'].".jpg");
        }
    // Various colors
        $textcolor = imagecolorallocate($im, 255, 255, 255);
        $border = imagecolorallocate($im, 135, 191, 231);
        $hpcolor = imagecolorallocate($im, 209, 48, 48);
        $mpcolor = imagecolorallocate($im, 204, 0, 255);
        $encolor = imagecolorallocate($im, 209, 184, 48);
        $oncolor = imagecolorallocate($im, 64, 225, 32);
        $offcolor = imagecolorallocate($im, 255, 80, 80);
        $rd = imagecolorallocate($im, 241, 241, 241);
        $rdblue = imagecolorallocate($im, 0, 180, 255);
while ($row = mysqli_fetch_assoc($result)){
    // Level and name
        imagestring($im, 3, 22, 28, "<Lv".$row['PvPKills']."> ".$row['Name'], $encolor);
    }       
    // Display image
        imagepng($im);
        imagedestroy($im);
mysqli_close($connection);
?>

在我的评论上展开:

<?php
$y = 28;
while ($row = mysqli_fetch_assoc($result)) {
    // Level and name
    imagestring($im, 3, 22, $y, "<Lv".$row['PvPKills']."> ".$row['Name'], $encolor);
    $y += 16;
}

最新更新