Я так понимаю ошибка в sql запроса но не могу понять какое
<?php
$conn = oci_connect("login", "password", "DB");
$g1 = $_POST['value_1'];
$g2 = $_POST['value_2'];
/*$g3 = $_POST['value_3'];
$g4 = $_POST['value_4'];
$g5 = $_POST['value_5'];
$g6 = $_POST['value_6'];*/
$g7 = $_POST['value_7'];
$g8 = $_POST['value_8'];
$g9 = $_POST['value_9'];
$query = "select ";
if ($g1 = 1) {
$query .= "sum(case when t.subs_subs_id = 244 then t.sum_real_volume/60 end),"; }
if ($g2 = 1) {
$query .= " sum(case when t.subs_subs_id = 246 then t.sum_real_volume/60 end),"; }
$query .= " trunc(t.start_date, '$g9')
from trafic t,
SUBSCRIBERS c
where c.subs_id = t.subs_subs_id
and t.start_date >= to_date('$g7', 'yyyy/mm/dd')
and t.start_date <= to_date('$g8', 'yyyy/mm/dd')
group by trunc(t.start_date, '$g9');";
$stid = oci_parse($conn, $query);
if (!$stid) {
$e = oci_error($conn);
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$r = oci_execute($stid);
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS))
{
print "<tr>\n";
foreach ($row as $item) {
echo '<td>' . ($item. "") . "</td>\n";
}
}
oci_free_statement($stid);
oci_close($conn);
?>