You are on page 1of 1

1 <?

php
2 //INCLUDE CONFIGURATION FILE
3 include('config.php');
4
5 //-----------------FETCHING SEARCH RESUL------------------------T
6 if(isset($_POST["query"]))
7 {
8 $search = mysqli_real_escape_string($conn, $_POST["query"]);
9 $query = "
10 SELECT * FROM images
11 WHERE file_name LIKE '%".$search."%'
12 OR name LIKE '%".$search."%'
13 ";
14 $result = mysqli_query($conn, $query);
15 if(mysqli_num_rows($result) > 0)
16 {
17
18 //----------CREATE CAPTION VIEW----------------
19 while($row = mysqli_fetch_array($result))
20 {
21 $imgWithPath = "upload/".$row['name'];
22 echo '
23 <table class="table">
24 <tr>
25 <td width="25%">';?>
26
27 <?php
28 $ext = $row['ext'];
29 if($ext == "pdf")
30 {
31 ?>
32
33 <iframe width="200" src="<?php echo $imgWithPath; ?>"></iframe>
34 <?php
35 }
36 else {
37 ?>
38 <img src="<?php echo $imgWithPath; ?>" width="200"/>
39 <?php } echo '</td>
40 <td width="75%"><a style="margin-top:0px; color:black;
font-size:25px;">'.$row["file_name"].'</a><br/>
41 <a style="font-size:18px; margin-top:0px;">'.$row["latter_no"].'</a>
42 <p>'.$row["remarks"].'</p>'; ?>
43 <a target="_blank" href="viewdoc.php?viewid=<?php echo $row["id"]; ?>"
class="btn btn-primary">View</a>
44 <a target="_blank" href="editdoc.php?viewid=<?php echo $row["id"]; ?>"
class="btn btn-success">Edit</a>
45 <a href="?deleteid=<?php echo $row["id"]; ?>" class="btn btn-danger">Delete</a>
46 </td>
47 </tr></table>
48 <?php
49 }
50 }
51 else
52 {
53 echo 'Data Not Found';
54 }
55 }
56 else
57 {
58 $query = "
59 SELECT * FROM images ORDER BY id";
60 }
61 ?>

You might also like