gpt4 book ai didi

php - 如何回显行中的总和值

转载 作者:行者123 更新时间:2023-11-30 01:02:05 24 4
gpt4 key购买 nike

我想将第一个脚本的总和回显到第二个脚本中

两者都是同一页面,我尝试过但不起作用示例

echo '<td>' . $row['status'] . '</td>';
echo '<td>' .$final_result4. '</td>';

我该怎么做,请帮我解决这个问题,谢谢......

这是我的第一个脚本

     $res1 = (($basicsalary+$allowsalary)*$days*$yeardays1)/$yeardays/$monthdays;
$res2 = (($basicsalary1+$allowsalary1)*$days*$yeardays2)/$yeardays/$monthdays;
$res3 = (($basicsalary2+$allowsalary2)*$days*$yeardays3)/$yeardays/$monthdays;
$res4 = (($basicsalary+$allowsalary)*$days*$yeardays4)/$yeardays/$monthdays;
$res5 = (($basicsalary1+$allowsalary1)*$days*$yeardays5)/$yeardays/$monthdays;
$res6 = (($basicsalary2+$allowsalary2)*$days*$yeardays6)/$yeardays/$monthdays;
$res8 = 221/730*$miscamount +$otheramount;
$res7 = $startdays -$enddays;

$result1 = number_format((round($res1, 1)),3);
$result2 = number_format((round($res2, 1)),3);
$result3 = number_format((round($res3, 1)),3);
$result4 = number_format((round($res4, 1)),3);
$result5 = number_format((round($res5, 1)),3);
$result6 = number_format((round($res6, 1)),3);
$result7 = number_format((round($res7, 1)),3);
$result8 = number_format((round($res8, 1)),3);




$final_result = number_format(($result1 +$result2 +$result3 +$result4 +$result5 +$result6 ),3);
$final_result2 = number_format((round($final_result/730*$result7 ,1 )),3);
$final_result3 = number_format((round(($final_result2 +$result8) , 1)),3);
echo $final_result4 = number_format((round(($final_result -$final_result3) , 1)),3);


//Ending of php
?>

这是我的第二个脚本

 echo "<span  align='center' class='style2'>Over All Report For The Period Of $a to $b</span>"; 
echo "<div id='testTable' id='non-printable'><table class='hovertable' border='1' cellpadding='10'>";
echo "<tr> <th>Date</th><th>Id</th><th>Name</th> <th>Division</th><th>Payment</th><th>Status</th><th>Total</th></tr>";


// get results1 from database
$result1 = mysql_query("SELECT * FROM fullfsaccounts where date BETWEEN '$a' AND '$b' order by date ASC");
while($row = mysql_fetch_array($result1))
{



// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['date'] . '</td>';
echo '<td>' . $row['cardno'] . '</td>';
echo '<td>' . $row['name'] . '</td>';
echo '<td>' . $row['division'] . '</td>';
echo '<td>' . $row['typecash'] . '</td>';
echo '<td>' . $row['status'] . '</td>';
echo '<td>' '</td>';
echo "</tr>";

//Increment the value of the Total_total variable
//by the salary value of one row till the while loop finishes
$Total_rows=$num=mysql_num_rows($result1);
$Total_total=$Total_total+$row['total'];

}
echo "</table>";

echo "<table class='hovertable' border='1' >";
echo "<tr width='100%'>";
echo '<td>Total</td>';
echo '<td>' . $Total_rows .'</td>';
echo '<td>' . $Total_total .'</td>';
echo "</tr>";



// close table>
echo "</table>";

最佳答案

在您的代码中,您在 echo '' '' 行中有一个基本错误;你的需要把 echo ''。 '';

我认为你也解释得不好,因为如果它们像你所说的那样位于同一页面上,那么调用页面局部变量的值就不会有任何问题。

我建议你使用不同的 -> echo 'pass';或 echo 'pass : '.resultxxx: in 控制页面的流程,我理解,如果它们位于同一页面上并且不出去走在其中,您应该能够获取局部变量的值,而无需有任何问题。

如果您需要帮助,请详细解释您的问题。

关于php - 如何回显行中的总和值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20030717/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com