在我的网站上,我有一个文件 articles.php ,我有一个搜索字段。当我输入信息时,它会将我重定向到我的 search.php ,这是正确的,并且在网址中我可以看到它正在输出我的结果,但它没有显示我在 search.php 正文中的结果。
我在搜索后输出了Localhost网址"你可以在Windows签证游戏"
http://localhost/qaa/search.php?search=Can+you+game+on+widows+vista&submit-search=
此页面上没有任何内容,只有一个空框 search.php
连接
<?php
$server = "localhost";
$username = "root";
$password = "";
$db = "Qaa";
$conn = mysqli_connect($server, $username, $password, $db);
?>
articles.php&#34;我的搜索栏位于&#34;
<?php
include 'connect.php';
?>
<h1>Front Page</h1>
<h2>All articles:</h2>
<link rel="stylesheet" type="text/css" href="css/article.css">
<div class="article-container">
<form action="search.php">
<input type="text" name="search" placeholder="Search">
<button type="submit" name="submit-search">Get answers</button>
</form>
<?php
$sql = "SELECT * FROM article";
$result = mysqli_query($conn, $sql);
$queryResults = mysqli_num_rows($result);
if ($queryResults > 0){
while ($row = mysqli_fetch_assoc($result)){
echo "<div class='article-box'>
<h3>".$row['a_title']."</h3>
<p>".$row['a_text']."</p>
<hp>".$row['a_date']."</p>
<p>".$row['a_author']."</p>
</div>";
}
}
?>
Search.php&#34;点击“获取答案”按钮&#39;&#34;
后,搜索信息应显示在哪里<?php
include 'connect.php';
?>
<link rel="stylesheet" type="text/css" href="css/article.css">
<h1>Search Page</h1>
<div class="article-container">
<?php
if (isset($_POST['submit-search'])){
$search = mysqli_real_escape_string($conn, $_POST['search']);
$sql = "SELECT * FROM article WHERE a_title LIKE '%$search%' OR a_text
LIKE '%$search%' OR a_author LIKE '%$search%' OR a_date LIKE '%$search%'";
$result = mysqli_query($conn, $sql);
$queryResult = mysqli_num_rows($result);
echo "There are ".$queryResult." results!";
if($queryResult > 0){
while ($row = mysqli_fetch_assoc($result)){
echo "<div class='article-box'>
<h3>".$row['a_title']."</h3>
<p>".$row['a_text']."</p>
<hp>".$row['a_date']."</p>
<p>".$row['a_author']."</p>
</div>";
}
}else{
echo "There are no results matching your search! Contact our support so
we can add this or if you have a result, add it, as a result, using the
GIVE ANSWER button!";
}
}
?>
</div>
答案 0 :(得分:0)
您正在使用$this->setOptionsKey('imageUpload', $this->module->imageUploadRoute);
$this->setOptionsKey('fileUpload', $this->module->fileUploadRoute);
$this->clientOptions['imageUploadErrorCallback'] = ArrayHelper::getValue($this->clientOptions, 'imageUploadErrorCallback', new JsExpression("function(json){alert(json.error);}"));
$this->clientOptions['fileUploadErrorCallback'] = ArrayHelper::getValue($this->clientOptions, 'fileUploadErrorCallback', new JsExpression("function(json){alert(json.error);}"));
if (isset($this->clientOptions['plugins']) && array_search('imagemanager', $this->clientOptions['plugins']) !== false) {
$this->setOptionsKey('imageManagerJson', $this->module->imageManagerJsonRoute);
}
if (isset($this->clientOptions['plugins']) && array_search('filemanager', $this->clientOptions['plugins']) !== false) {
$this->setOptionsKey('fileManagerJson', $this->module->fileManagerJsonRoute);
}
哪个错了。因为您的搜索字符串是在get方法中提交的。所以你必须使用: -
$_POST['search']
请试一试。