保存foreach的结果



我为以下脚本开发了foreach函数

function kali($src, $key, $pengali)
{
    echo $pengali . ' x ' . $src . ' = ' . $pengali * $src . '<br/>';
}
$tampil = mysql_query(" SELECT DISTINCT term FROM `term` order by term  ");
while ($t = mysql_fetch_array($tampil)) {
    $term    = $t[term];
    $array   = array();
    $tampil2 = mysql_query(" select term, id_document, wdt from wdt where term = '$term' order by id_document  ");
    while ($t = mysql_fetch_array($tampil2)) {
        $term        = $t[term];
        $id_document = $t[id_document];
        $wdt         = $t[wdt];
        $wdt_r       = round($wdt, 2);
        $array[]     = $wdt_r;
    }
    foreach ($array AS $item => $value) {
        $temporary = array_shift($array);
        array_walk($array, 'kali', $value);
    }
}

我想把foreach函数、id_document和term中计算的乘法结果保存到数据库中。

我能在这里帮个忙吗?

完成计算后运行查询将数据插入数据库:

mysql_query("INSERT INTO table_name (id_document, term) VALUES ($id_document, $term)");

让我知道的进展情况

最新更新