目前我的查询搜索了'可用性'使用以下代码;
$status = 'available';
$stmt = $pdo->query('SELECT * FROM orders WHERE idorder = "' . $status . '"');
$results = $stmt->fetchAll();
我的问题是;如何更改$ status中的变量?'可用'到输入搜索框的内容?
答案 0 :(得分:1)
这是您的搜索页面:
myhtml.php
<?php
if(isset($_POST["btnsubmit"]) && !empty($_POST["btnsubmit"]))
{
$status = $_POST["status"];
$stmt = $pdo->query('SELECT * FROM orders WHERE idorder = "' . $status . '"');
$results = $stmt->fetchAll();
}
?>
<form action="myhtml.php" method="POST">
<input type="text" name="status">
<input type="submit" value="Submit" name="btnsubmit">
</form>
答案 1 :(得分:0)
的index.html
<form action="file.php" method="get">
<input type="text" name="status">
<input type="submit" value="Submit">
</form>
File.php
<?php
$status=$_GET['status'];
$stmt = $pdo->query('SELECT * FROM orders WHERE idorder = "' . $status . '"');
$results = $stmt->fetchAll();
?>