I did a function that calculates the total price, by a specific user and his cart shopping, with PHP.
I`m getting this error:
Parse error: syntax error, unexpected '$user' (T_VARIABLE), expecting function (T_FUNCTION) or const (T_CONST) in C:\xampp\htdocs\myPrograms\projectTest.php on line 43.
This is my code (the problematic line is the 2nd line below):
Class bill {
$username= 'almog';
echo "Your total price for this bought is:" .Total_bill($username). "Dollars"."<br>";
function Total_bill($username)
{
$total = 0;
$query= $this-> db->query ("select serial_number, count_purchase, price_item from bought_history LEFT JOIN
product ON bought_history. serial_number = product. serial_number where username=username and date_purchase= date_purchase");
foreach($query as $key=> $value )
{
if ($bought_history. $serial_number->$count_purchase ==1)
{
$total = $total + $product. $serial_number->$price_item;
}
else
{
$total = $total + ($product. $serial_number->$price_item * $bought_history. $serial_number->$count_purchase);
}
}
return $total;
}
}