如果没有结果,我想将搜索词(例如 foo 的含义)提交到表单中
细节:
我有一个带有 if else 条件的搜索功能,如果有搜索结果而不是显示带有“未找到搜索结果”的 else 消息
我想通过一个表单提交来更改“未找到搜索结果”,其中值将是用户尝试查找的任何搜索词。所以...
if search result found {
//display result
} else {
// auto submit below form if above condition is not true ( means if no search result found )
<form action="to url" method="post">
<input name="title" type="text" />
</form>
}
以上是我用来提交表格的表格。
编辑:
这是实际的代码
.......
if (count($results))
$qa_content['title']=qa_lang_html_sub('main/results_for_x', qa_html($inquery));
else { ?>
<form id="nosearch" method="POST" action="<?php echo qa_opt('site_url'); ?>ask" class="top-askbox" >
<input name="title" type="text" value="<?php echo $inquery; ?>">
</form>
<script>$("#nosearch").submit();</script>
<?php }
.......
这是我工作的部分。实际文件太长。