hi guys.
I got problem here. I built the system of weighted average method calculation based on php. Now, I'm the last part which sum of the value in html table. Basically, this is my coding:-
<?php
session_start();
$con = mysql_connect("localhost","root","");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("supplier", $con);
$criteria_weight = isset($_REQUEST['criteria_weight']) ? $_REQUEST['criteria_weight'] :"";
$criteria_weight2 = isset($_REQUEST['criteria_weight2']) ? $_REQUEST['criteria_weight2'] :"";
$criteria_weight3 = isset($_REQUEST['criteria_weight3']) ? $_REQUEST['criteria_weight3'] :"";
$criteria_weight4 = isset($_REQUEST['criteria_weight4']) ? $_REQUEST['criteria_weight4'] :"";
$criteria_weight5 = isset($_REQUEST['criteria_weight5']) ? $_REQUEST['criteria_weight5'] :"";
$criteria_weight6 = isset($_REQUEST['criteria_weight6']) ? $_REQUEST['criteria_weight6'] :"";
$criteria_weight7 = isset($_REQUEST['criteria_weight7']) ? $_REQUEST['criteria_weight7'] :"";
$criteria_weight8 = isset($_REQUEST['criteria_weight8']) ? $_REQUEST['criteria_weight8'] :"";
$criteria_weight9 = isset($_REQUEST['criteria_sweight9']) ? $_REQUEST['criteria_weight9'] :"";
$profile = mysql_query("SELECT * FROM `supplier_criteria` "
. "WHERE `criteria_weight` = '" . $_SESSION['weights1'] . "'"
. " AND `criteria_weight2` = '" . $_SESSION['weights2'] ."'"
. " AND `criteria_weight3` = '" . $_SESSION['weights3'] ."'"
. " AND `criteria_weight4` = '" . $_SESSION['weights4'] ."'"
. " AND `criteria_weight5` = '" . $_SESSION['weights5'] ."'"
. " AND `criteria_weight6` = '" . $_SESSION['weights6'] ."'"
. " AND `criteria_weight7` = '" . $_SESSION['weights7'] ."'"
. " AND `criteria_weight8` = '" . $_SESSION['weights8'] ."'"
. " AND `criteria_weight9` = '" . $_SESSION['weights9'] ."';");
$query = "SELECT MAX(details_value) as processor FROM supplier_details WHERE details_status = 'in process'";
$result = mysql_query($query) or die(mysql_error());
$query2 = "SELECT MIN(details_value) as processor2 FROM supplier_details WHERE details_status = 'in process' ";
$result2 = mysql_query($query2) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$max = $row['processor'];
}
while($row2 = mysql_fetch_array($result2)){
$min = $row2['processor2'];
}
echo "<table border='1'>";
$result = mysql_query ("SELECT * FROM supplier_details WHERE details_status='in process'");
for($i=0; $i<$result; $i++)
{
while($row = mysql_fetch_array($result)){
{
echo '<td width="40" valign="center">';
$i = 0;
while ($i<'1')
{
if ($row['details_threshold']=='min'){
$avg_min = @( $row[14]-$min)/($max-$min);
$i++;
echo round($avg_min,2);
}
else{
$avg_max = @($max-$row[14])/($max-$min);
$i++;
echo round($avg_max,2);
}
}
echo "</td>";
}
}
}
$query = "SELECT MAX(details_value2) as processor FROM supplier_details WHERE details_status = 'in process'";
$result = mysql_query($query) or die(mysql_error());
$query2 = "SELECT MIN(details_value2) as processor2 FROM supplier_details WHERE details_status = 'in process' ";
$result2 = mysql_query($query2) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$max = $row['processor'];
}
while($row2 = mysql_fetch_array($result2)){
$min = $row2['processor2'];
}
echo "<table border='1'>";
$result = mysql_query ("SELECT * FROM supplier_details WHERE details_status='in process'");
for($i=0; $i<$result; $i++)
{
while($row = mysql_fetch_array($result)){
{
echo '<td width="40" valign="center">';
$i = 0;
while ($i<'1')
{
if ($row['details_threshold']=='min'){
$avg_min = @( $row[15]-$min)/($max-$min);
//echo $row[15];
$i++;
echo round($avg_min,2);
}
else{
$avg_max = @($max-$row[15])/($max-$min);
$i++;
echo round($avg_max,2);
}
}
echo "</td>";
}
}
}
?>
all of this went at the right direction which the result will be:
0.62 1 0
0 1 1
total 0.62 2 1
but the things is I don't know how to make the value of total. can anyone help me?
p/s:- I'm just newbie in php.