我有一個index.php頁面,我添加了一個與數據庫連接的搜索表單。因此,當用戶搜索任何單詞時,結果將顯示在數據庫中。一旦在頁面上生成結果,我希望用戶將結果導出到.doc文件中。
我只想將查詢結果導入到.doc文件中,但由於某些原因我得到一個空白的.doc文件。
這裏是我的代碼:
searchform:
<form id="searchform" method="post">
<input type="text" name="searchit" id="searchit" class="txt" />
<input type="submit" value="Search" id="button" class="button" />
</form>
查詢:
<?php
include("database.php");
$term = strip_tags(substr($_POST['searchit'],0, 100));
$term = $mysqli->real_escape_string($term);
if($term=="") {
echo "<div class='error'>Enter Something to search</div>";
exit();
}
termcheck($term, $mysqli);
function termcheck($term, $mysqli){
$qry="Select * from pogel where title = '$term'";
if($result = $mysqli->query($qry)){
$num_rows = $result->num_rows;
if($num_rows > 0) {
while($row = $result->fetch_assoc())
{
echo "Stem : ".$row['title']."<br>";
}
}
}
}
?>
[PHP的可能重複: 「請注意:未定義的變量」 和「注意:未定義的索引「](http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index) – FirstOne
您的HTML頁面中是否有名稱爲」searchit「的元素哪些發送POST數據? – Phiter
是的,'searchhit'已經在我的搜索頁面上,但仍然出現錯誤。 – Mehreen