我正在从桌子上获取信息。它设置为varchar。我无法更改它,因为当我这样做时,它的所有内容都为0。我需要能够将结果除以12。这是MY-TotalPrem需要除的。
我尝试了
<td>'.$row["MS-TotalPrem" / 12].'
</td>, <td>'.$row["MS-TotalPrem"] / 12.'</td>,
<td>'.$row[int("MS-TotalPrem") / 12].
'</td>
,没有任何作用。
function fetch_customer_data($connect)
{
$query = "SELECT * FROM mytable";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$output = '
<div class="table-responsive">
<table class="table table-striped table-bordered">
<tr>
<th>Name</th>
<th>Address</th>
<th>Address</th>
<th>Policy Number</th>
<th>Total Monthly</th>
<th>Expiration Date</th>
</tr>
';
foreach($result as $row)
{
$output .= '
<tr>
<td>'.$row["AC-AcctName"].'</td>
<td>'.$row["PM-PropertyAddr1"].'</td>
<td>'.$row["PO-Addr1"].'</td>
<td>'.$row["PO-PrefixPolNum"].'</td>
<td>'.$row["MS-TotalPrem"].'</td>
<td>'.$row["PO-ExpDate"].'</td>
</tr>
';
}
$output .= '
</table>
</div>
';
return $output;
}
我只希望输出为12的除数或我输入的任何其他数字。谢谢。
答案 0 :(得分:2)
function fetch_customer_data($connect)
{
$query = "SELECT * FROM mytable";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$output = '
<div class="table-responsive">
<table class="table table-striped table-bordered">
<tr>
<th>Name</th>
<th>Address</th>
<th>Address</th>
<th>Policy Number</th>
<th>Total Monthly</th>
<th>Expiration Date</th>
</tr>
';
foreach($result as $row)
$output .= '
<tr>
<td>'.$row["AC-AcctName"].'</td>
<td>'.$row["PM-PropertyAddr1"].'</td>
<td>'.$row["PO-Addr1"].'</td>
<td>'.$row["PO-PrefixPolNum"].'</td>
<td>'.($row["MS-TotalPrem"] / 12).'</td>
<td>'.$row["PO-ExpDate"].'</td>
</tr>
';
$output .= '
</table>
</div>
';
return $output;
}