2017-09-27 8 views
0

誰かがこのコードを手伝ってくれるのだろうか?クエリーでデータをプルし、そのデータをイメージに配置するように設計されています。しかし、私は、クエリのすべての行が毎回新しい行ではなく、互いの上に印刷されるという問題を抱えています。私はそれが私が見落としているシンプルなものだと確信していますが、どんな助けもありがとう!また、それは建設中であり、きちんと見えません!だから、明確にするために、私はすべての行をループして縦リストに表示するようにしていますが、現在はラインブレイクせずにすべての行を表示しています!私のコメントに拡大すること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); 

?> 
+0

私はあなたが毎回同じ座標を使っているからだと仮定 - (22、28)。毎回Y座標を増やす必要があります。どのくらい私は分かりませんが、16ピクセルで試してそこから調整することができます。 –

答えて

0

<?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; 
} 
+0

華麗な、これはトリックをやっている、ありがとう、お元気です! – Samo

+0

@Samo喜んで助けました。答えを受け入れるように親切にしてください。 =) –

関連する問題