我在MySQL数据库中有100,000条记录。我想自动生成一个表来显示。这是我所做的代码。生成自动行但仍有错误。我需要你的帮助。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Random 10 - Random Packet Sampling</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
.style1 {color: #FFFFFF}
.style109 {font-size: 12px}
.style115 {font-family: Arial, Helvetica, sans-serif}
.style118 {font-size: 12px;
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
}
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style8 {color: #000000}
.style9 {color: #FF0000}
-->
</style>
</head>
<body>
<?php
include_once ("connection.php");
$data = mysql_query("SELECT * FROM trying");
$result = array();
while ($data2 = mysql_fetch_array($data))
array_push($result, array('no'=> $data2['no'],
'time'=> $data2['time'],
'source'=> $data2['source'],
'destination'=>$data2['destination'],
));
$rand = array();
$step = 10;
for ($min = 0; $min <= 49; $min = $min + $step)
{
$max = $min + $step;
$rand[] = $result[rand($min,$max)];
}
//echo json_encode($rand);
?>
<h1>Random Packet Sampling</h1>
<h2>Random 10</h2>
<p> </p>
<table width="980" id="rounded-corner">
<thead>
<tr bgcolor="#FF9900">
<th width="34" bgcolor="#FFFFFF" class="rounded-company"><div align="center"><strong><span class="style33 style115">No.</span></strong></div></th>
<th width="108" bgcolor="#FFFFFF"><div align="center"><strong><span class="style33 style115">No</span></strong></div></th>
<th width="241" bgcolor="#FFFFFF"><div align="center"><strong><span class="style33 style115">Time</span></strong></div></th>
<th width="224" bgcolor="#FFFFFF"><div align="center"><strong><span class="style33 style115">Sourc</span></strong></div></th>
<th width="156" bgcolor="#FFFFFF"><div align="center"><strong><span class="style33 style115">Destination</span></strong></div></th>
<!--<th width="100" bgcolor="#FFFFFF"><div align="center"> <strong><span class="style33 style115">Mark</span></strong></div></th>-->
</tr></thead>
<?php $i = 0;
$c=1;
do { ?>
<tr bgcolor="#FFF9CE">
<td height="20" bgcolor="#FFFFFF"><div align="center" class="style8"><span class="style118">
<?php
if($page>0){
$x=($page*10)+$c;
}else{$x=$c;}
?>
<?php echo $x?></span></div></td>
<td bgcolor="#FFFFFF"><div align="center" class="style8"><span class="style30 style61 "><?php echo $rand[0]; ?></a></span></div></td>
<td bgcolor="#FFFFFF"><div align="center" class="style109 style8"><span class="style30 style61 "><?php echo $rand[1]; ?></span></div></td>
<td bgcolor="#FFFFFF"><div align="center" class="style109 style8"><span class="style30 style61 "><?php echo $rand[2]; ?></span></div></td>
<td bgcolor="#FFFFFF"><div align="center" class="style109 style8"><span class="style30 style61 "><?php echo $rand[3]; ?></span></div></td>
</tr>
<?php $c++; } while (count($rand)); ?>
<tfoot>
<tr>
<td colspan="6" class="rounded-foot-left"><?php
echo count ($rand); echo records;
?></td>
<td width="188" class="rounded-foot-right"> </td>
</tr>
</tfoot>
</table>
<br/><br/>
</body>