我有一个模态窗口,其中包含一个文本框和一个搜索按钮。现在我想要的是当用户输入一个单词然后点击“搜索”按钮时,我希望它运行查询并显示结果,不管结果是否存在。
问题是我不知道如何让“搜索”按钮在被删除后输出必要的细节。目前,如果用户在输入单词后点击“搜索”按钮,则没有任何反应。
所以我只想要一个与“搜索”按钮关联的常规功能,以便在单击搜索按钮后输出详细信息。如何实现这一目标?
以下是application的链接,以便您了解正在发生的事情。
以下是完整代码:
<div class="previouslink">
<button type="button" id="close" onclick="return closewindow();">Close</button>
<h1>PREVIOUS QUESTIONS</h1>
<?php
foreach (array('questioncontent') as $varname) {
$questioncontent = (isset($_POST[$varname])) ? $_POST[$varname] : '';
}
?>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<p>Search: <input type="text" name="questioncontent" value="<?php echo $questioncontent; ?>" /></p>
<p><input id="searchquestion" name="searchQuestion" type="submit" value="Search" /></p>
</form>
<?php
if (isset($_POST['searchQuestion'])) {
$questionquery = "SELECT QuestionContent FROM Question
WHERE(QuestionContent = '".mysql_real_escape_string($questioncontent)."')";
$questionnum = mysql_num_rows($questionresult = mysql_query($questionquery));
?>
<p>
Your Search: <?php echo "'$questioncontent'"; ?>
</p>
<?php
if($questionnum ==0){
echo "<p>Number of Questions Shown from the Search: <strong>$questionnum</strong></p>";
echo "<p>Sorry, No Questions were found from this Search</p>";}
else{
echo"<p>Number of Questions Shown from the Search: <strong>$num</strong></p>";
$output = "";
$output .= "
<table border='1'>
<tr>
<th>Question</th>
</tr>
";
while ($questionrow = mysql_fetch_array($questionresult)) {
$output .= "
<tr>
<td>{$questionrow['QuestionContent']}</td>
</tr>";
}
$output .= " </table>";
echo $output;
}
if (empty($questioncontent)){
echo "Please enter in a phrase in the text box in able to search for a question";
}
}
mysql_close();
?>
</div>
以下更新:
<body>
<?php
if (isset($_POST['searchQuestion'])) {
echo "xxx";
exit;
}
?>
<form id="QandA" action="imageupload.php" method="post">
<h1>CREATING QUESTIONS AND ANSWERS</h1>
<table id="plus" align="center">
<tr>
<th>
<a onclick="return plusbutton();">
<img src="Images/plussign.jpg" width="30" height="30" alt="Look Up Previous Question" class="plusimage"/>
</a>
<span id="plussignmsg">(Click Plus Sign to look <br/> up Previous Questions)</span>
</th>
</tr>
</table>
<div class="previouslink">
<button type="button" id="close" onclick="return closewindow();">Close</button>
<h1>PREVIOUS QUESTIONS</h1>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<p>Search: <input type="text" name="questioncontent" /></p>
<p><input id="searchquestion" name="searchQuestion" type="submit" value="Search" /></p>
</form>
</div>
</form>
</body>
答案 0 :(得分:0)
您应该将输入标记移到<form method="POST"> </form>
块内。
答案 1 :(得分:0)
尝试调试点击按钮搜索时所获得的内容使用退出查看您的查询列表,
当没有表格没有动作时,点击搜索使用正确的代码格式化
就不会发生任何事情