<span>$invoicepartpaid1</span>
和的结果为<span>$invoicepartpaid2</span>
空白。应该有金额。有什么建议么?
$query="SELECT Distinct company, car_moto, packet FROM companies where userid='$userid' ORDER BY company, car_moto, packet";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$f0=mysql_result($result,$i,"company");
$f1=mysql_result($result,$i,"car_moto");
$f2=mysql_result($result,$i,"packet");
$sql_1 = "SELECT SUM(price_protect) as partpaid1 FROM companies where company='$f0' and car_moto='$f1' and packet='$f2' and userid='$userid'";
$sql_2 = "SELECT SUM(clear_protect) as partpaid2 FROM companies where company='$f0' and car_moto='$f1' and packet='$f2' and userid='$userid'";
$result_1=mysql_query($sql_1) or die('Error query failed');
$result_2=mysql_query($sql_2) or die('Error query failed');
while ($row_1 = mysql_fetch_array($result_1)) {
$invoicepartpaid1 = $row_1['partpaid1'];
}
while ($row_2 = mysql_fetch_array($result_2)) {
$invoicepartpaid2 = $row_2['partpaid2'];
}
echo "<tr><td align='center'><span>$f0</span></td><td align='center'><span>$f1</span></td><td align='center'><span>$f2</span></td>";
echo "<td align='center'><span>$invoicepartpaid1</span></td><td align='center'><span>$invoicepartpaid2</span></td></tr>";
$i++;
}