i wrote the following query and it work fine in mysql but when i place it in php code and place variables in the query it don't give out put on php page
original SQL query
Select sum (sum1) from (select employ_name,(sum * employ_pay) as sum1 from (SELECT hours.auto_id,hours.employ_name,sum(employ_hours)as sum,
empoly.employ_type,empoly.employ_pay
FROM hours left join empoly on
hours.employ_name=empoly.employ_name
and date_hours
between
'20080101'
and
'20081230'
where employ_type = 'front'
group by employ_name) as sa )sb
now in php with veriables
<?php
$total_front=" Select sum (sum1) from (select employ_name,(sum * employ_pay) as sum1 from (SELECT hours.auto_id,hours.employ_name,sum(employ_hours)as sum,
empoly.employ_type,empoly.employ_pay
FROM hours left join empoly on
hours.employ_name=empoly.employ_name
and date_hours
between
'".$_POST['from_date']."'
AND
'".$_POST['to_date']."'
where employ_type = 'front'
group by employ_name) as sa )as sb"
$result_total_front= mysql_query ($total_front)
or die (mysql_error());
while ($ftotall = mysql_fetch_assoc ($result_total_front)) {
foreach ($ftotall as $valtotall)
{
echo " Weekly Front of the house = ";
echo $valtotall;
}
}
?>
i know there should be ; after
'".$_POST['to_date']."'
because its a php function it don't work also tried placing ; after "group by employ_name)" still the same result if i place ; at the end of the the whole query i get error message "FUNCTION mydata_data.sum does not exist" i know its a php codeing problem and placing ; at the right place with right quotes will work any help will be helpful