Beispiel #1
0
//echo ''.$sql_default.'\n';
$sql_default = mysql_query($sql_default) or die(mysql_error());
$count_default = mysql_num_rows($sql_default);
if ($count_default > 0) {
    $cpi_value = array();
    $cpi_growth = array();
    $cpi_growth_first = array();
    $cpi_growth_year = array();
    $cpi_time = array();
    $cpi_rose = 0;
    $previous = 0;
    $first_value = 0;
    $last_value = 0;
    while ($row = mysql_fetch_array($sql_default)) {
        $period = $row['time_cpi_' . $table_search];
        $value_yearback = getyearbackValue('cpi_' . $table_search . '_value', $table_search, 'id_' . $table_search, '' . $byDefaut, $period);
        $total = $row['cpi_' . $table_search . '_value'];
        if ($previous === 0) {
            $growth = ($total / $pvalue - 1) * 100;
            $growth_first = 0;
            $first_value = $total;
            $growth_year = ($total / $value_yearback - 1) * 100;
        } else {
            $growth = ($total / $previous - 1) * 100;
            $growth_first = ($total / $first_value - 1) * 100;
            $growth_year = ($total / $value_yearback - 1) * 100;
            //            echo ''.$growth.'<br>';
        }
        $previous = $total;
        $last_value = $total;
        //            echo 'period:'.$period.':val:'.$total.' <br>';
Beispiel #2
0
function getrwandaup()
{
    $table_Search = 'group';
    $sql_pmonth = "SELECT `cpi_" . $table_Search . "_value`,`time_cpi_" . $table_Search . "` FROM `cpi_data_" . $table_Search . "` WHERE `id_" . $table_Search . "`='00' and `time_cpi_" . $table_Search . "` = (select max(`time_cpi_" . $table_Search . "`)from `cpi_data_" . $table_Search . "` )";
    //    echo ''.$sql_pmonth;
    $sql_pmonth = mysql_query($sql_pmonth);
    while ($row = mysql_fetch_array($sql_pmonth)) {
        $pvalue = $row['cpi_' . $table_Search . '_value'];
        $ptime = $row['time_cpi_' . $table_Search];
        $yearbackValue = getyearbackValue("cpi_" . $table_Search . "_value", $table_Search, "id_" . $table_Search, "00", $ptime);
        $recentvalue = (floatval($pvalue) / floatval($yearbackValue) - 1) * 100;
        return $recentvalue;
    }
    return 0;
}