-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsearch.php
More file actions
executable file
·107 lines (89 loc) · 3.5 KB
/
Copy pathsearch.php
File metadata and controls
executable file
·107 lines (89 loc) · 3.5 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
session_start();
require_once ('include/header.php');
require_once ('include/dbconfig.php');
$username = $_SESSION['username'];
$keyword = "%" . $_GET['q'] . "%";
$pdo = db_connect();
$log = $pdo -> prepare(
"insert into log(username, operation, target)
values (:username, :operation, :target)"
);
$operation = "search for";
$log -> bindParam(":username", $username, $pdo::PARAM_STR);
$log -> bindParam(":operation", $operation, $pdo::PARAM_STR);
$log -> bindParam(":target", $_GET['q'], $pdo::PARAM_STR);
$log -> execute();
$stmt = $pdo -> prepare(
"select *
from Project
where pname like :keyword or pdescription like :keyword or tags like :keyword"
);
$stmt -> bindParam(":keyword", $keyword, $pdo::PARAM_STR);
$stmt -> execute();
$result = $stmt -> fetchAll();
function showAllProject($singleResult) {
$createTime = $singleResult['createT'];
$endTime = $singleResult['endFT'];
$completeTime = $singleResult['endPT'];
$fundSoFar = $singleResult['fundSoFar'];
$author = $singleResult['pOwner'];
$pid = $singleResult['pid'];
$pname = $singleResult['pname'];
$pdescription = $singleResult['pdescription'];
$allTags = $singleResult['tags'];
echo
<article class='portfolio-item pf-media pf-icons clearfix'>
<div class='portfolio-image'>
<a href='project.php?pid=$pid'>
<img src='projectimage.php?pid=$pid' alt='$pname'>
</a>
</div>
<div class='portfolio-desc'>
<h3><a href='project.php?pid=$pid'>$pname</a></h3>
<span>$allTags</span>
<p>$pdescription</p>
<ul class='iconlist'>
<li><i class='icon-ok'></i> <strong>Created:</strong>$createTime</li>
<li><i class='icon-ok'></i> <strong>End Fund:</strong>$endTime</li>
<li><i class='icon-ok'></i> <strong>Complete:</strong>$completeTime</li>
<li><i class='icon-ok'></i> <strong>Collected:</strong>$fundSoFar</li>
<li><i class='icon-ok'></i> <strong>By:</strong>$author</li>
</ul>
<a href='project.php?pid=$pid' class='button button-3d noleftmargin'>Have A Look</a>
</div>
</article>
";
}
?>
<!-- Page Title
============================================= -->
<section id="page-title">
<div class="container clearfix">
</div>
</section><!-- #page-title end -->
<!-- Content
============================================= -->
<section id="content">
<div class="content-wrap">
<div class="container clearfix">
<h2>Search Result about '<?php echo $_GET['q']; ?>'</h2>
<div id="portfolio-shuffle" class="portfolio-shuffle" data-container="#portfolio">
<i class="icon-random"></i>
</div>
<div class="clear"></div>
<!-- Portfolio Items
============================================= -->
<div id="portfolio" class="portfolio grid-container portfolio-1 clearfix">
<?php
foreach($result as $row) {
showAllProject($row);
}
?>
</div><!-- #portfolio end -->
</div>
</div>
</section><!-- #content end -->
<?php
require_once ('include/footer.html');
?>