<form action="send_post.php" method="post">
<p>A: <input type="text" name="A">
<p>B: <input type="text" name="B">
<p><input type="submit">
</form>
<?php
$db = "localhost"; $usr = "blah1"; $pword = "blah2"; $dbname = "blah3";
-----connects to server ok -------
$A = mysqli_real_escape_string($conn, $_POST['A']);
$B = mysqli_real_escape_string($conn, $_POST['B']);
$query="SELECT * FROM blah4 where A=$A and B=$B";
$sql=mysqli_query($conn, $query);
echo $sql;
$conn->clos();
?>
从数据库显示数据需要什么?
答案 0 :(得分:1)
您的查询字符串格式不正确
<form action="send_post.php" method="post">
<p>A: <input type="text" name="A"> </p>
<p>B: <input type="text" name="B"> </p>
<p><input type="submit"> </p>
</form>
<?php
$db = "localhost"; $usr = "blah1"; $pword = "blah2"; $dbname = "blah3";
-----connects to server ok -------
$A = mysqli_real_escape_string($conn, $_POST['A']);
$B = mysqli_real_escape_string($conn, $_POST['B']);
$query="SELECT * FROM blah4 where A='$A' and B='$B'";
$sql=mysqli_query($conn, $query);
echo $sql;
$conn->close();
?>
或
$query="SELECT * FROM blah4 where A='". $A ,"' and B='" .$B ."'";
您还没有关闭</p>
和
$conn->close();
答案 1 :(得分:0)
要添加不实际从db获取数据,请尝试此
$row->mysqli_result::fetch_object($query);
那么你可以得到某些字段,比如你有一个用户名字段
username = $row->username;
然后你可以显示像
这样的用户名echo $username;