check file encode, with example notepad++ or php version, rly idk :D
or if u need just write result to file.
<?php
$host = ''; //Hosting
$user = ''; //Username
$pass = ''; //Password
$db = ''; //DatabaseName
$top = '100'; //Top Number
$countpvp = 1;
try {
$conn = new PDO("mysql:host=$host;dbname=$db", $user, $pass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->query("SET NAMES 'utf8'");
}
catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
$out = "
<table>
<tr>
<th align='left'>Name</th>
<th align='right'> </th>
<th align='right'>PvP</th>
</tr>
";
$pvp = "SELECT char_name, pvpkills FROM characters WHERE pvpkills > 0 AND accesslevel <= 0 ORDER by pvpkills DESC LIMIT $top ";
$pvp = $conn->prepare($pvp);
$pvp->execute();
while($row = $pvp->fetch() ) {
$countpvp++;
$out .=
"
<tr>
<td align='left'><span>".$row['char_name']."</span></td>
<td align='right'><span> </span></td>
<td align='right'>".$row['pvpkills']."</td>
</tr>
";
}
$out .= "
</table>
";
file_put_contents("test.doc",$out); // this save doc to next to index.php
?>