Run a query to insert data into database after you finish calculations:
mysql_query("INSERT INTO table_name (id_document, term) VALUES ($id_document, $term)");
Let me know how it goes
Question
I have developed foreach function for the following script
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);
}
}
I would like to save the result of multiplication that have been calculated in foreach function, id_document
and term to the database.
Can I have a little help here?
Solution
Run a query to insert data into database after you finish calculations:
mysql_query("INSERT INTO table_name (id_document, term) VALUES ($id_document, $term)");
Let me know how it goes