【发布时间】:2021-09-05 11:11:48
【问题描述】:
我的 html 页面包含 5 个字段。他们不一定都被告知。 方法 post 将字段的内容发送到 php 页面。 查询只能从数据库中提取与填写的字段相关的行。 html 页面发送请求,但数据库不返回任何内容。我不知道问题出在 html 端还是 php 页面上。 我挡在了复杂的整体面前。
主页:
<tr>
<td style="font-family: 'Conv_Muli-Italic'; font-size: 16px; text-align: center; font-weight: bold; color: #808080;">
<form action = "ocr6.php" method = "POST">
<p> </p>
<table width="100%">
<tbody>
<tr>
<th scope="col">TYPE THE WORD OF YOUR CHOICE IN TEXT FIELDS. </th>
</tr>
</tbody>
</table>
<p> </p>
<table width="100%" align="center">
<tbody>
<tr>
<th scope="col"><p>NAME</p>
<p>
<input name="nom" type="text" />
</p></th>
<th scope="col"><p>STATE</p>
<p>
<input name="nom2" type="text" />
</p></th>
<th scope="col"><p>CATEGORY</p>
<p>
<input name="nom3" type="text" />
</p></th>
<th scope="col"><p>DETAIL</p>
<p>
<input name="nom4" type="text" />
</p></th>
<th scope="col"><p>ORIGINE</p>
<p>
<input name="nom5" type="text" />
</p></th>
</tr>
ocr6.php:
<?php
$mysqli = new mysqli("localhost", "....", "mot de passe", "mabase");
if ($mysqli->connect_errno) {
die('<p>Connexion impossible : '.$mysqli->connect_error.'</p>');
}
$nom = $_POST['nom'];
$nom2 = $_POST['nom2'];
$nom3 = $_POST['nom3'];
$nom4 = $_POST['nom4'];
$nom5 = $_POST['nom5'];
$stmt = $mysqli->prepare("SELECT FROM fiveC2 WHERE name LIKE ? OR state LIKE ? OR category LIKE ? OR detail LIKE ? OR origine LIKE ? LIMIT 0, 3000");
$stmt->bind_param("sssss", '%$nom%', '%$nom2%', '%$nom3%', '%$nom4%', '%$nom5%');
$stmt->execute();
$result = $stmt->get_result();
if (!$result) {
die('<p>ERREUR Requête invalide : '.$mysqli->error.'</p>');
}
while ($row = $result->fetch_assoc()) {
$recherche = $row['recherche'] ;
echo '<p>'.$recherche.'</p>'."\r\n" ;
}
$result->free() ;
$mysqli->close() ;
?> </p>
</blockquote>
</ul>
<p><strong> - END OF REQUEST - </strong></p>
</div>
</div>
</div>
</div>
</body>
</html>
感谢您的帮助。
【问题讨论】:
-
婆罗多,欢迎来到 SO。你什么都没问!你有什么问题?
-
Bharata 还考虑在这两个文件上关闭 html 标记。 ;)