1 回答
TA贡献1786条经验 获得超13个赞
我已经通过使用 php 代码而不是 JS 标签解决了这个问题。
我创建了另一个名为 db.php 的 .php 文件,内容如下:
<?php
$servername = "MyServerIP";
$username = "user_name";
$dbname = "db_name";
$password = "some_password";
$saeedIsCool = new mysqli($servername, $username, $password, $dbname);
if ($saeedIsCool->connect_error) {
die("Connection failed: " . $saeedIsCool->connect_error);
}
$sql = "SELECT monthly FROM tblpricing WHERE id = 1";
$result = $saeedIsCool->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$id1Product = "". $row["monthly"]." Toman";
}
} else {
echo "0 results";
}
$floorid1Product = floor($id1Product). " Toman";
$saeedIsCool->close();
?>
并修改了我的 test.php 内容如下:
<?php
include ("./name.php");
include ("./db.php");
echo "The price of {$name} is {$floorid1Product} Toman per month";
?>
现在结果如预期:
IRcPanel-A 的价格是 11200 Toman/月
- 1 回答
- 0 关注
- 137 浏览
添加回答
举报