= '5') {
  $sql  = "SELECT * FROM `storage` AS S, `devices` AS D WHERE S.host_id = D.device_id ORDER BY D.hostname, S.hrStorageDescr";
} else {
  $sql  = "SELECT * FROM `storage` AS S, `devices` AS D, devices_perms as P WHERE D.host_id = D.device_id AND ";
  $sql .= "D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.hrStorageDescr";
}
$query = mysql_query($sql);
echo("
        ");
echo("
        | Device | 
        Storage | 
        Usage | 
         | 
        Size | 
        Used | 
      
");
$row = 1;
while($drive = mysql_fetch_array($query)) {
  if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
    $total = $drive['hrStorageSize'] * $drive['hrStorageAllocationUnits'];
    $used  = $drive['hrStorageUsed'] * $drive['hrStorageAllocationUnits'];
    $perc  = round($drive['storage_perc'], 0);
    $total = formatStorage($total);
    $used = formatStorage($used);
    $store_url    = "graph.php?id=" . $drive['storage_id'] . "&type=unixfs&from=$month&to=$now&width=400&height=125";
    $store_popup = "onmouseover=\"return overlib('
', LEFT);\" onmouseout=\"return nd();\"";
    $drv_colour = percent_colour($perc);
    echo("| " . generatedevicelink($drive) . " | " . $drive['hrStorageDescr'] . " | 
           
           | " . $perc . "% | " . $total . " | " . $used . " | 
");
    $row++;
}
echo("
 ");
?>