sasha199
Member
Hello everyone, there is such a problem I have a page with about 10 cacl elements, there I make a query to the database and output the results, everything works fine, but when I turn on the final calculation, the page gives an error (0) and refuses to work, how to change the query to make the built-in calculator work?
PHP:
$element = $_POST['month'];
$firstday2 = '{sbrh2_datebase___id}';
if ($element > 0) {
$test = "LAST_DAY('$element-01') + INTERVAL 1 DAY - INTERVAL 1 MONTH";
$test2 = "LAST_DAY('$element-01') + INTERVAL 1 DAY";
}
else
{
$test = "LAST_DAY(CURDATE()) + INTERVAL 1 DAY - INTERVAL 1 MONTH";
$test2 = "LAST_DAY(CURDATE()) + INTERVAL 1 DAY";
}
$dbb = JFactory::getDbo();
$query='SELECT SUM(zp_day) FROM sbrh2_tabel_pers_log WHERE id = ANY(SELECT max(id) FROM sbrh2_tabel_pers_log WHERE familia = '.$firstday2.' GROUP BY date) AND DATE >= '.$test.' AND DATE <= '.$test2.' AND familia = '.$firstday2.' AND id_spec = 7';
$dbb->setQuery($query);
$datavalue = $dbb->loadResult();
return $datavalue;