Hi,
I am trying to use information from a database to do some simple calculations. I am struggling with turning the information into variables and then using these variables in some calculations.
Here is the code i have so far. If i delete calc 1, 2 and 3 it will display all the data.
<?PHP
$host="localhost";
$username="root";
$password="root";
$db_name="research";
$tbl_name="users";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$query = "SELECT windows, heating FROM users WHERE username ='test'";
$result = mysql_query($query);
while($row = mysql_fetch_row($result))
{
$windows = $row[0];
$heating = $row[1];
$calc1 = ($heating*0.1);
$calc2 = ($windows*100);
$calc3 = (($windows*100)/$heating*0.1));
echo "<h2>Double Glazing Savings Calculator</h2>" .
"<p>Number of Windows: $windows</p>" .
"<p>Yearly Heating Cost: £$heating</p>" .
"<p>Cost of Replacement: £$calc2</p>" .
"<p>Annual Saving: £$calc1</p>" .
"<p>Payback Period: $calc3 years</p>"
}
?>
Can anyone please help me?
Will