我试图在php中运行此代码,但不打印任何内容。
我的数据库不为空。
Convert.ToDecimal
EX: 我在我的数据库中记录了这个用户 用户=穆赫辛 链接:
答案 0 :(得分:1)
您正在混合面向对象和程序样式查询。
<?php
$dbname = "mytest";
$servername = "***";
$username = "mohsen";
$passwords = "****";
// Create connection
$conn = new mysqli($servername, $username, $passwords, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$User=$_POST['username'];
$sql="SELECT * FROM Money WHERE Debtor='$User' OR Creditor='$User' ";
$result = $conn->query($sql);
//
while($field = $result->fetch_object())
{
print $field->Debtor."|";
print $field->Creditor."|";
print $field->Cost."|";
print $field->Status."|"."\n";
}
$conn->close();
?>
答案 1 :(得分:0)
<?php
$dbname = "mytest";
$servername = "***";
$username = "mohsen";
$passwords = "****";
// Create connection
$conn = new mysqli($servername, $username, $passwords, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$User=$_POST['username'];
$sql="SELECT * FROM Money WHERE Debtor='$User' OR Creditor='$User' ";
$result = $conn->query($sql);
while($field=$result->fetch_assoc())
{
print $field["Debtor"]."|";
print $field["Creditor"]."|";
print $field["Cost"]."|";
print $field["Status"]."|"."\n";
}
$conn->close();
?>