我需要将逗号和美元符号插入代表货币的数字字符串中。最好用网站代码或sqlcmd完成,看起来会是什么样的?
网页:
<div id='week'>
<?php
echo "<table>\n\n";
$f = fopen("week.csv", "r");
while (($line = fgetcsv($f)) !== false) {
echo "<tr>";
foreach ($line as $cell) {
echo "<td>Past Week: $" . htmlspecialchars($cell) . "</td>";
}
echo "</tr>\n";
}
fclose($f);
echo "\n</table>";
?>
</div>
CSS文件:
body {
background-position:center;
background-image: url(background.jpg);
background-repeat: no-repeat;
}
#title {
margin-top:300px;
font-size: 50px;
text-align: center ;
Font-family: Arial;
color: white;
}
#week td {
font-size: 30px;
text-align: center ;
Font-family: Arial;
color: red;
}
#week {
border-color: white;
height:50px;
width:350;
position:relative;
margin-left: auto;
margin-right: auto;
margin-top:10px;
批处理文件:
sqlcmd -S myserver -U username -P password -d money -Q "declare @today datetime = '2014-5-21' set nocount on; select [Week Total] = (convert(varchar, convert(decimal(18, 2), sum([TotalJackpotAmount])), 3)) from [Accounting].[dbo].[HandPay] where [AccountingDate] <= @today and [AccountingDate] > dateadd(week, -1, @today);" -o \\location\to\write\file\Week.csv -h -1 -s ","
如果需要CSS,我也可以上传。
答案 0 :(得分:1)
您可以使用number_format
foreach ($line as $cell) {
echo "<td>Past Week: $" . number_format(htmlspecialchars($cell)) . "</td>";
}