我不记得该怎么做。我正在尝试从数据库中的表中获取所有条目,并将其列出到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>
最佳答案
应该是这样
<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>
<?php
while ($row = mysql_fetch_array($sql)) { ?>
<tr>
<td><?php echo $row['name']; ?></td>
// Rest of other values
<tr>
<?php } //End while?>
</table>
关于php - 将表格中的所有信息列出到html表格中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12400820/