-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
27 lines (24 loc) · 1009 Bytes
/
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
<?php
$db = new SQLITE3 ('./db/sqlite.db');
$search = SQLite3::escapeString($_POST['search']);//Prevent sql injection
$res = $db->query("SELECT * FROM Posts WHERE comment LIKE '%$search%' OR email LIKE '%$search%' ORDER BY ID desc"); //Select rows from database where email or comment contains $search
while ($row = $res->fetchArray())
{
$temp = $row['email'];
$res2 = $db->query("SELECT * FROM User WHERE email = '" . SQLite3::escapeString($temp) . "'");
echo $row["email"];
echo "<br>";
if($row2 = $res2->fetchArray())
{
echo "<img src='images/".$row2['image']."' width=60 height=60>";
}
echo "<br>";
echo "---";
echo "<br>";
echo $row["comment"];
echo "<br>";
echo "-------------------------------------------------------------------";
echo "<br>";
echo "<br>";
}
?>