Can you put and if statement in a variable?
I have this code that works fine but I want to be able to call on an if statement later on down the page to get a grand total. What I am tying to do is at the bottom of the code
while($row = mysql_fetch_array($result))
{
echo "Timecard for: <b>" . $row['name'] . "</b>";
echo "<br />";
echo "Clocked in at: " . $row['time_in'];
echo "<br />";
echo "Current time: $time";
echo "<br />";
$timein = $row['time_in'];
$to_time=strtotime("$time");
$from_time=strtotime("$timein");
$diff=round(abs($to_time - $from_time) / 60);
echo "Total time: $diff minutes";
echo "<br />";
//******Adult total********//
echo " Total per adult: ";
$adults = ($row['adults']);
$intfee = 12.00; // $12 min. fee
$minchrg = .40; //cents over minimum time
$first = 30.00; //min
$totaltime = ($diff - 6);
$over = ($totaltime - $first); // min over minimum time
$adultpay = ($intfee *$adults);
if ($totaltime <= $first) {
echo "$$adultpay * including 6 <b><u>FREE</u></b> minutes";
}
if ($totaltime > $first) {
$overmin = ($over * $minchrg + $intfee);
$overminadultspay = ($over * $adults);
echo "$$overminadultspay * including 6 <b><u>FREE</u></b> minutes";
}
echo "<br />";
$kids = ($row['kids']);
$intfeekid = 9.00; // $12 min. fee
$minchrgkid = .30; //cents over minimum time
$firstkid = 30.00; //min
$totaltime = ($diff - 6);
$over = ($totaltime - $first); // min over minimum time
$kidspay = ($intfeekid * $kids);
//*******kid total************//
echo "Total per child: ";
function adulttotal() { if ($totaltime <= $firstkid) {
echo "$$kidspay * including 6 <b><u>FREE</u></b> minutes";
}
if ($totaltime > $first) {
$overmin = ($over * $minchrgkid + $intfee);
$overminkidpay = ($overmin * $kids);
echo "$$overminkidpay * including 6 <b><u>FREE</u></b> minutes";
}}
echo "<br />";
echo "Grand total: "; // how to get the sum of adult and kid here?
I think that function might help but everything I have tried has not worked. any advice is greatly appreciated.
Thanks DXM