我的 php 代码是这样的:
<?php
$con=mysqli_connect("host","user","pass","db_name");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result_set = mysqli_query($con,"SELECT points FROM total WHERE id = 1");
$row = mysqli_fetch_assoc($result_set);
$old_total = $row['points'];
$new_total = $old_total + $_REQUEST['total'];
mysqli_query($con,"UPDATE total SET points = $new_total WHERE id = 1");
mysqli_close($con);
?>
所以现在我需要 $new_total 显示在我的 html 页面上,请帮助我。
<小时/>这是我使用的最终代码:
<?php include 'something.php'; ?>
<h3> <?php echo $new_total?> </h3>
最佳答案
将此文件包含在主页中,然后将此代码放入主页中,您将能够看到输出:
<?php echo $new_total ?>
关于php - 从表中请求数据并以 html 形式显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15287652/