-
Notifications
You must be signed in to change notification settings - Fork 0
/
backend-searchQA.php
51 lines (46 loc) · 1.09 KB
/
backend-searchQA.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<html>
<body>
<?php
include("connection.php");
$sql = "SELECT *FROM help";
// Escape user inputs for security
$term = $_POST['term'];
?>
<div class="containerQA2">
<div class="col-md-12">
<?php
if(!empty($term)){
?>
<?php
// Attempt select query execution
$sql = $sql." WHERE question LIKE '%" . $term . "%' or answer LIKE '%" . $term . "%'";
}
if($result = mysqli_query($conn, $sql)){
error_log("$sql..",3,"databaseoperations.log");
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_array($result)){
?>
<?php
echo "Question: " . $row['question'] . "<br/>Answer: ". $row['answer'] ."<br>";
echo "<br>";
}
?>
</div>
</div>
<?php
echo"<table border=50 BORDERCOLOR=#000000 width=100%>
<tr><th> </th><th>End of search</th></tr>";
}
else{
echo "<tr><td colspan=4>No matches found</td></tr>";
}
}
else{
$errorconn=mysqli_error($conn);
trigger_error("$errorconn ");
}
// close connection
mysqli_close($conn);
?>
</body>
</html>