I've a page index.php where I added a search form that's connected with the database. So that When users search any word, result would show up from database. Once results generated on the page I want users to export the result into a .doc file.
I want only the query results into the .doc file but for some reasons I'm getting a blank .doc file.
Here are my codes:
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>
Query:
<?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>";
}
}
}
}
?>