我不记得如何做到这一点。我正在尝试从数据库中的表中获取所有条目,并将其列表到 html 表中。我还试图将从表中提取的条目数限制在 10 到 20 之间。
//Connection Info
include('data.php');
//Query To Pull Data
$sql = mysql_query("select name, death, model, humanity, hkills, bkills, kills, hs, late, ldrank, stime, survival, lastupdate from $stats order by kills limit 10");
//Data Pulled To Be Displayed
while ($row = mysql_fetch_array($sql)) {
//Username
$name = $row['name'];
//Deaths
$death = $row['death'];
//Amount of Humanity
$humanity = $row['humanity'];
//Player Type
$model = $row['model'];
//Murders
$murder = $row['hkills'];
//Bandit Kills
$bandit = $row['bkills'];
//Zombie Kills
$zombie = $row['kills'];
//Head Shots
$head = $row['hs'];
//Unknown
$late = $row['late'];
//Unknown
$ldrank = $row['ldrank'];
//Unknown
$stime = $row['stime'];
//Time Survived
$survival = $row['survival'];
//Last Time Player Was On
$update = $row['lastupdate'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="1000" border="1">
<tr>
<th scope="col">Username</th>
<th scope="col">Type</th>
<th scope="col">Friendliness</th>
<th scope="col">Deaths</th>
<th scope="col">Murders</th>
<th scope="col">Bandit Kills</th>
<th scope="col">Zombie Kills</th>
<th scope="col">Head Shots</th>
<th scope="col">Late</th>
<th scope="col">STime</th>
<th scope="col">Time Survived</th>
<th scope="col">LDRank</th>
<th scope="col">Last Played</th>
</tr>
<tr>
<td><? echo "$name"; ?></td>
<td><? echo "$model"; ?></td>
<td><? echo "$humanity"; ?></td>
<td><? echo "$death"; ?></td>
<td><? echo "$murder"; ?></td>
<td><? echo "$bandit"; ?></td>
<td><? echo "$zombie"; ?></td>
<td><? echo "$head"; ?></td>
<td><? echo "$late"; ?></td>
<td><? echo "$ldrank"; ?></td>
<td><? echo "$stime"; ?></td>
<td><? echo "$survival"; ?></td>
<td><? echo "$update"; ?></td>
</tr>
</table>
</body>
</html>