我想将第一个脚本的总和回显到第二个脚本
两者都是同一页我尝试但不工作 示例
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>";
答案 0 :(得分:0)
在您的代码中,您在行回显''''中有一个基本错误;你的需要 把回声放''。 '';
我认为你也不能很好地解释,因为如果它们和你说的页面相同,你就不应该有任何问题来调用页面局部变量的值。
我建议你加上不同的 - &gt; echo'pass';或者echo'pass:'。resultxxx:在控制页面的流程中,我明白如果它们在同一页面上并且没有走出去并且进入它,你应该能够获取局部变量的值而不用任何问题。
如果您需要帮助,请详细说明您的问题。