forked from if-itb/IF3110-2015-T1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
68 lines (65 loc) · 1.75 KB
/
search.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php include_once("header.php");
include_once("functions.php");
?>
<div class="search-area">
<center>
<form method="get" action="search.php" id="search">
<input type="text" id="search-box" name="s">
<input type="submit" id="search-submit" value="Search">
</form>
<div id="search-desc">
Cannot find what you are looking for. <a href="ask.php">Ask here</a>.
</div>
</center>
</div>
<div class="content">
<div id="recent-title">Search Result</div>
<hr>
<?php
if(empty($_GET["s"])){
//don't show result
} else {
$keyword = $_GET["s"];
$result = search($keyword);
$result->bind_result($id, $name, $email, $topic, $content, $answers, $votes, $create_date, $update_date);
while ($result->fetch()) {
?>
<div class="question-item" id="question-<?php echo $id;?>">
<table>
<tr>
<td>
<?php echo $votes;?></br>
Votes
</td>
<td>
<?php echo countAnswers($id);?></br>
Answers
</td>
</td>
<td>
<?php echo "<a class=\"question-item-topic\" href=\"view.php?q=".$id."\"?><strong>".$topic."</strong></a></br>".$content;?>
<div class="question-item-tag">
<?php echo "Asked by <span class='question-item-name'>" . $name."</span>";
echo " | ";
echo "<a href='edit.php?q=" .$id. "'>edit</a>";
echo " | ";
echo "<a class=''><span onclick='delQuestion(".$id.")' class='question-item-delete'>delete</span></a>";
?>
</div>
</td>
</tr>
</table>
<hr>
</div>
<?php
}
?>
<div class="question-list">
<?php
}
?>
</div>
</div>
</div>
</body>
</html>