用户使用PHP进行计算的两个数据

May I know how exactly equation in PHP works? All my data can be extracted well, but how can I get two data fromuser which are $method=$_GET['method']; and $valueinsert=$_GET['valueinsert'];.

$valueinsert=$_GET['valueinsert'];
                        $method=$_GET['method'];
                        error_reporting(E_ALL ^ E_DEPRECATED);
                        //connect to the server
                        $connect= mysql_connect("127.0.0.1","root","");
                        //$conn = new mysqli($servername, $username, $password);
                        if(!$connect)
                        {
                        die('Could not connect: '.mysql_error($connect));
                        }
                        //connect to the database
                        mysql_select_db("fyp",$connect);

                        $query5 = "SELECT method, SUM(revenue), SUM(cost) FROM `table 1` WHERE method = '$method'"; 
                        $result5 = mysql_query($query5) or die(mysql_error());

                        $sql="SELECT * FROM `table 1` WHERE method='$method'";
                        $query=mysql_query($sql,$connect);

                        echo"<table align=center width='80%'>";
                            echo"<td valign='top' width='20%'> ";
                            echo "<b><u>$method </u></b>" ;
                                echo "</br>";
                                while($row = mysql_fetch_array($result5)){
                                    echo "Total Profit = RM ". round($row['SUM(revenue)']- ($row['SUM(cost)']- '$valueinsert' ) ,2);
                                    echo "<br />";
                                }

                        echo"</table>";
                        ?>

Change the query to this

Method 1

$query4 = "SELECT Method, SUM(cost) as cost, SUM(revenue) as revenue FROM `table 1` WHERE Method = '$Method'"; 

And also in fetching the result side. Should be like this

   echo "Total Gross Margin = RM ". round($row['revenue']- $row['cost'] / $row['revenue'],2);

Method 2

echo "Total Gross Margin = RM ". round($row['(SUM(Revenue)-SUM(cost))/SUM(Revenue)'],2);

You can obtain the result directly in sql too

  "SELECT 
    Method
  , SUM(cost) as cost
  , SUM(revenue) as revenue
  , (SUM(Revenue)-SUM(cost))/SUM(Revenue) as result  
  FROM `table 1` 
  WHERE Method = '$Method'";