-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
35 lines (27 loc) · 969 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
28
29
30
31
32
33
34
<?php
session_start();
include 'database/connect.php';
include 'functions.php';
include 'langCheck.php';
protect();
$query = $con->prepare("SELECT user_id FROM users WHERE username = ?");
$query->bind_param("s", $_SESSION['user']);
$query->execute();
$query->bind_result($user_id);
$query->fetch();
$query->close();
$t = $_POST['text'];
$text = "%".$t."%";
$data = array();
$query = $con->prepare("SELECT id, title FROM snippets WHERE title LIKE ? AND user_id = ?");
$query->bind_param("ss", $text, $user_id);
$query->execute();
$query->bind_result($snippetId, $title);
while($query->fetch()){
if(!empty($t))
echo "<div data-snippetId=$snippetId onclick='if (event.target === this) getSnippet($snippetId);' class='snippet'><p onclick='if (event.target === this) getSnippet($snippetId);'>@ $title</p><span onclick='editSnippet($snippetId);'><i class='las la-pencil-square-o'></i></span></div>";
else
echo "";
}
$query->close();
?>