我从数据库中获取数据并将其插入此表中。
while (($result_row = $result->fetch_assoc()) !== NULL) {
echo "<tr>";
echo "<td>", $result_row['title'], "</td>";
echo "<td>", $result_row['author'], "</td>";
echo "<td>", $result_row['isbn'], "</td>";
echo "<td>", $result_row['price'], "</td>";
echo "</tr>";
}
我似乎无法弄清楚如何以价格打印实际的$。有什么建议吗?
答案 0 :(得分:3)
echo "<td>\$", $result_row['price'], "</td>";
或更好,请使用money_format()http://php.net/manual/en/function.money-format.php
答案 1 :(得分:2)
echo "<td>$", $result_row['price'], "</td>";