我不知道是否有人可以帮我用这段代码?它被设计为用查询拉取数据,然后将所述数据放入图像中。但是,我有一个问题,查询的所有行都被打印出来,而不是每次换行。我相信这是我忽略的简单东西,但任何帮助将不胜感激!同样对不起,它正在建设中,看起来并不整齐!所以要清楚,我正在寻找它遍历所有行,并将它们显示在垂直列表中,但是,它当前将所有行都显示出来,而不会有任何换行符!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);
?>
我想这是因为你使用同样的坐标每次 - (22,28)。你应该每次增加Y坐标。多少,我不知道,但你可以尝试16像素,并从那里调整。 –