hi all,
I've got the following code which pulls all the data from the MySQL table and puts it into an array then returns each result.
I'm trying at the bottom to get one large total for all the results added together. Currecntly its displaying the sumation for each result found.
Hope that makes sense. I guess what I'm trying to say is how do I remove it from the while loop?

I've got the following code which pulls all the data from the MySQL table and puts it into an array then returns each result.
I'm trying at the bottom to get one large total for all the results added together. Currecntly its displaying the sumation for each result found.
Hope that makes sense. I guess what I'm trying to say is how do I remove it from the while loop?
Code:
<?php
include("connect.php");
$sitename=$_GET['q'];
//This is the query for the administration;
//we are obtaining all articles that are available with all columns.
$query="select * from siteform where sitename ='" .$sitename. "'";
//This runs the query to view
//If we get a positive result in $results, it will process the while loop
If ($results = mysql_query ($query)) {
//Creates the diplay table
}
?>
<?php
if (mysql_num_rows($results)>0){
While ($row = mysql_fetch_array($results)) {
//inputs the data into the table
$id = stripslashes($row['id']);
$price = stripslashes($row['price']);
$consumption = stripslashes($row['consumption']);
$hours = stripslashes($row['hours']);
?>
<br />
<font color=#FF0000>kWh * ADU = </font><?php $sum_total = $consumption * $hours;
$kwh = $sum_total * $price;
echo $kwh; ?><br />
</p>
<?php
}
}
else{
echo "The site survey for <font color=#FF0000>$sitename</font> has not yet been carried out";
}
?>
<?php
mysql_close();
?>
