我在 PHP 中创建了一个简单的 html 表。这是我的代码:图表->
<div id="wrapper">
<div class="chart">
<h2>No. of Files Uploaded to Knowledge Base</h2>
<table id="data-table" border="1" cellpadding="10" cellspacing="0">
<tr>
<td>Users</td>
<td>Project Files</td>
<td>Process Files</td>
<td>System Files</td>
<td>Total</td>
</tr>
<?php
$di = new RecursiveDirectoryIterator('upload/project/');
foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
$pos = 15;
$file = substr("$filename", +$pos);
$lenght = strlen($file);
$pos = strpos($file, "/");
$file = substr("$file",0,$pos);
if($file1 != '.DS_Store'){
$serverfiles = mysql_query("SELECT uploader FROM Project WHERE location = '$file'");
while($row = mysql_fetch_array($serverfiles)) {
$occurance1 = $row['uploader'];
$array1[] = $occurance1;
}
}
}
$di = new RecursiveDirectoryIterator('upload/process/');
foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
$pos = 15;
$file = substr("$filename", +$pos);
$lenght = strlen($file);
$pos = strpos($file, "/");
$file = substr("$file",0,$pos);
if($file != '.DS_Store'){
$serverfiles = mysql_query("SELECT uploader FROM Process WHERE processlocation = '$file'");
while($row = mysql_fetch_array($serverfiles)) {
$occurance2 = $row['uploader'];
$array2[] = $occurance2;
}
}
}
$di = new RecursiveDirectoryIterator('upload/system/');
foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
$pos = 14;
$file = substr("$filename", +$pos);
$lenght = strlen($file);
$pos = strpos($file, "/");
$file = substr("$file",0,$pos);
if($file != '.DS_Store'){
$serverfiles = mysql_query("SELECT uploader FROM System WHERE location = '$file'");
while($row = mysql_fetch_array($serverfiles)) {
$occurance3 = $row['uploader'];
$array3[] = $occurance3;
}
}
}
$uploader = mysql_query("Select username from members");
while($Load = mysql_fetch_array($uploader)){
$value = $Load['username'];
$tmp = array_count_values($array1);
$cnt = $tmp[$value];
echo"<tr>";
echo"<td>$value</td>";
echo "<td>$cnt</td>";
$value2 = $Load['username'];
$tmp2 = array_count_values($array2);
$cnt2 = $tmp2[$value2];
echo "<td>$cnt2</td>";
$value3 = $Load['username'];
$tmp3 = array_count_values($array3);
$cnt3 = $tmp3[$value3];
$total = $cnt + $cnt2 + $cnt3;
echo "<td>$cnt3</td>";
echo "<td>$total</td>";
}
echo "</tr>";
?>
</table>
</div>
</body></html>
用户是从数据库表中填充的。通过读取和计算目录中的文件数量来填充文件数字。我希望能够按总数字自动对表格进行排序,因此总数字最高的用户将排在首位,依此类推......所以它看起来类似于排行榜。
我不知道该怎么做。有人可以指导我正确的方向吗?