I have created a simple html table within PHP. Here is my code: Chart -->
<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>
The users are populated from a database table. The file figures are populated by reading and counting the amount of files in the directory. I want to be able to automatically sort the table by the total figure so the user with the highest total figure will be on top and first and so on..so it will look similar to a league table.
I do not know how to do this. Can someone please guide me in the right direction?