美好的一天!我有一個總報告表,我想從GETT數據庫中的值和數字的格式,並有一個像這樣PHP 10,000.00輸出不喜歡這個php echo貨幣格式加上金額
這裏是我的審判PHP代碼。我有一張用於打印總報告的表格,並在格式化總金額時遇到問題。
function printpage()
{
window.print()
}
</script></head>
<body>
<br>
<br>
<div class="container">
<center>
<div class="alert alert-success" align="center"><h1>TOTAL REPORT</h1></div>
<br />
<table class="table table-striped table-bordered" border="1" width="900">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Address</th>
<th>Start of Event</th>
<th>End of Event</th>
<th>Quantity</th>
<th>Amount</th>
<th>Status</th>
<th>Confirmation</th>
</tr>
</thead>
<tbody>
<?php
$con=mysql_connect("localhost","root","")or die(mysql_error());
$db=mysql_select_db('pm')or die(mysql_error());
$query=mysql_query("select * from reservation ")or die(mysql_error());
while($row=mysql_fetch_array($query)){
$id=$row['id'];
?>
<tr>
<?php $row['id'] ?>
<td><?php echo $row['firstname'] ?></td>
<td><?php echo $row['lastname'] ?></td>
<td><?php echo $row['address'] ?></td>
<td><?php echo $row['arrival']?></td>
<td><?php echo $row['departure'] ?></td>
<td><?php echo $row['result'] ?></td>
<td><?php
$number = 'payable';
$payable = 0;
setlocale(LC_MONETARY,"en_PHP");
echo $row("The price is %i", $payable);
?> </td>
<td><?php echo $row['status'] ?></td>
<td><?php echo $row['confirmation'] ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<?php
$result = mysql_query("SELECT sum(payable) FROM reservation") or die(mysql_error());
while ($rows = mysql_fetch_array($result)) {
?>
<?php }
$result1 = mysql_query("SELECT result(qty) FROM rooinventory") or die(mysql_error());
while ($rows1 = mysql_fetch_array($result1)) {
?>
<div class="pull-right">
<div class="span">
<div class="alert alert-info"><i class="icon-credit-card icon-large"> </i> Total Amount: <?php echo $rows1['sum(p)']; ?></div>
</div>
</div>
</center>
<?php } ?>
mysql已棄用,請使用mysqli或PDO。 –