I cannot figure out how to format the number returned As 'project_exp' in the query. Tried formatting through the query and adding an if statement to php. No luck. Can anyone give me direction?
<?php //amount due
include("header.inc");
$sql = "SELECT project, SUM(airline_rr)+(SUM(auto_miles)*AVG(amt_per_mile))+SUM(motel)+
SUM(meals)+SUM(exp_amount)+SUM(broker_fee) AS project_exp
FROM expenses
WHERE soc_sec = \"$soc_sec\" AND
date >= \"$start_date\" AND date <= \"$end_date\"
GROUP BY project";
$sql_result = mysql_query($sql,$connection) or die ("Couldn't execute query.");
if (!$sql_result) {
echo "<p>Couldn't get records!";
} else {
//fetch row and assign meaningful names to var
while ($row = mysql_fetch_row ($sql_result))
{
print ("<TR><td width=100 align=left> </td>\n");
for ($i = 0; $i < mysql_num_fields $ql_result); $i++)
{
printf ("<TD width=200 align=left><b><font size=3>%s</font></b></TD>\n", htmlspecialchars ($row[$i]));
}
print ("<TR>\n");
}
mysql_free_result ($sql_query);
}
?>
Thanks, php Novice
<?php //amount due
include("header.inc");
$sql = "SELECT project, SUM(airline_rr)+(SUM(auto_miles)*AVG(amt_per_mile))+SUM(motel)+
SUM(meals)+SUM(exp_amount)+SUM(broker_fee) AS project_exp
FROM expenses
WHERE soc_sec = \"$soc_sec\" AND
date >= \"$start_date\" AND date <= \"$end_date\"
GROUP BY project";
$sql_result = mysql_query($sql,$connection) or die ("Couldn't execute query.");
if (!$sql_result) {
echo "<p>Couldn't get records!";
} else {
//fetch row and assign meaningful names to var
while ($row = mysql_fetch_row ($sql_result))
{
print ("<TR><td width=100 align=left> </td>\n");
for ($i = 0; $i < mysql_num_fields $ql_result); $i++)
{
printf ("<TD width=200 align=left><b><font size=3>%s</font></b></TD>\n", htmlspecialchars ($row[$i]));
}
print ("<TR>\n");
}
mysql_free_result ($sql_query);
}
?>
Thanks, php Novice