From: Joseph Adams <joeyadams3.14159@gmail.com>
[ccan] / web / search.php
1 <?php
2 session_start();
3 include('logo.html');
4 include('menulist.html');
5 include('configuration');
6 include('searchengine.php');
7 include('search.html');
8
9 if(isset($_POST['search'])) {
10         $searchtext = $_REQUEST['searchtext'];
11         $in = $_REQUEST['searchmenu'];
12         if(trim($searchtext) == '') { 
13                 echo '<div align="center"><font color="RED">Please enter some keyword to search</font></div>';
14                 exit();
15         } 
16         $searchtext = '%'.$searchtext.'%';
17 }
18 else if($_GET['author'] != '') {
19         $searchtext = '%'.$_GET['author'].'%';
20         $in = "author";
21 }       
22 else if ($_GET['disp'] == 'all') {
23         $searchtext = "%";
24         $in = "module";
25 }
26 else if ($_GET['disp'] != '') {
27         $searchtext = $_GET['disp'].'%';
28         $in = "module";
29 }       
30         
31 else 
32         exit();
33         
34 $result = searchdb($searchtext, $in, $db);
35 echo '<table align="left" border="0" cellpadding="8" cellspacing="1">';
36 if($row = sqlite3_fetch_array($result)) 
37         echo "<tr><td><a href=\"dispmoduleinfo.php?module=".$row['module']."\">".$row["module"]."</a></br>".
38                                 "<a href=\"search.php?author=".$row["author"]."\">".$row["author"]."</a> : ". $row["title"].
39                                         " </br> </br></td></tr>";
40 else
41         echo '<div align="center"><font color="RED"> No results found</font></div>';
42 while($row = sqlite3_fetch_array($result)) {    
43         echo "<tr><td><a href=\"dispmoduleinfo.php?module=".$row['module']."\">".$row["module"]."</a></br>".
44                                 "<a href=\"search.php?author=".$row["author"]."\">".$row["author"]."</a> : ". $row["title"].
45                                         " </br> </br></td></tr>";
46 }
47 echo '</table>';
48 ?>