SampleReporting

From Wiki
Jump to: navigation, search

<?php

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die
('Error connecting to mysql');

$dbname = 'tamany';
mysql_select_db($dbname);


echo "any\tusers0\tusers1\tusers2\tusers3\n";

for ($i = 1992; $i <= 2012; $i++) {

        echo $i . " ";

        for ($j = 0; $j < 4; $j++) {

                $sql = "SELECT sum(tamany) as aa from $dbname where databaixa like '%$i' and lloc like '%users$j%'";
                $result = mysql_query("$sql") or die ('error select');

                while($row = mysql_fetch_array( $result )){

                      if (!is_null ($row['aa']))
                          echo  $row['aa']/1024 ;
                      else
                          echo "0";

                }

                echo "\t";
        }

        echo  "\n";
}

mysql_close($conn);

?>

Personal tools
Namespaces
Variants
Actions
Navigation
Content
Toolbox