root/original/common/search.php

Revision 1, 3.2 KB (checked in by andrewgunn, 14 years ago)

Added original EVE-Killboard.net source code.

Line 
1<?
2  require_once( "class.page.php" );
3  require_once( "db.php" );
4  require_once( "globals.php" );
5
6  $page = new Page( "Search" );
7
8  $html .= "<form id=search action=\"?a=search\" method=post>";
9  $html .= "<table class=kb-subtable><tr>";
10  $html .= "<td>Type:</td><td>Text: (3 letters minimum)</td>";
11  $html .= "</tr><tr>";
12  $html .= "<td><select id=searchtype name=searchtype><option value=pilot>Pilot</option><option value=corp>Corporation</option><option value=alliance>Alliance</option></select></td>";
13  $html .= "<td><input id=searchphrase name=searchphrase type=text size=30/></td>";
14  $html .= "<td><input type=submit name=submit value=Search></td>";
15  $html .= "</tr></table>"; 
16  $html .= "</form>";
17 
18  if ( $_POST['searchphrase'] != "" && strlen( $_POST['searchphrase'] ) >= 3 ) {
19    switch ( $_POST['searchtype'] ) {
20      case "pilot":
21        $sql = "select plt.plt_id, plt.plt_name, crp.crp_name
22                  from kb3_pilots plt, kb3_corps crp
23                 where lower( plt.plt_name ) like lower( '%".slashfix( $_POST['searchphrase'] )."%' )
24                   and plt.plt_crp_id = crp.crp_id
25                 order by plt.plt_name";
26        $header = "<td>Pilot</td><td>Corporation</td>";
27        break;
28      case "corp":
29        $sql = "select crp.crp_id, crp.crp_name, ali.all_name
30                  from kb3_corps crp, kb3_alliances ali
31                 where lower( crp.crp_name ) like lower( '%".slashfix( $_POST['searchphrase'] )."%' )
32                   and crp.crp_all_id = ali.all_id
33                 order by crp.crp_name";
34        $header = "<td>Corporation</td><td>Alliance</td>";
35        break;
36      case "alliance":
37        $sql = "select ali.all_id, ali.all_name
38                  from kb3_alliances ali
39                 where lower( ali.all_name ) like lower( '%".slashfix( $_POST['searchphrase'] )."%' )
40                 order by ali.all_name";
41        $header = "<td>Alliance</td><td></td>";
42        break;
43    }
44   
45    $qry = new DBQuery();
46    if ( !$qry->execute( $sql ) )
47      die ( $qry->getErrorMsg() );
48
49    $html .= "<div class=block-header>Search results</div>";
50   
51    if ( $qry->recordCount() > 0 ) {
52      $html .= "<table class=kb-table width=450 cellspacing=1>";
53      $html .= "<tr class=kb-table-header>".$header."</tr>";
54    }
55    else
56      $html .= "No results.";
57     
58    while ( $row = $qry->getRow() )
59    {
60      $html .= "<tr class=kb-table-row-even>";
61      switch ( $_POST['searchtype'] ) {
62        case "pilot":
63          $html .= "<td><a href=\"?a=pilot_detail&plt_id=".$row['plt_id']."\">".$row['plt_name']."</a></td><td>".$row['crp_name']."</td>";
64          break;
65        case "corp":
66          $html .= "<td><a href=\"?a=corp_detail&crp_id=".$row['crp_id']."\">".$row['crp_name']."</a></td><td>".$row['all_name']."</td>";
67          break;
68        case "alliance":
69          $html .= "<td><a href=\"?a=alliance_detail&all_id=".$row['all_id']."\">".$row['all_name']."</a></td><td></td>";
70          break;
71      }
72      $html .= "</tr>";
73    }
74    if ( $qry->recordCount() > 0 )
75      $html .= "</table>";
76  } 
77 
78  $page->setContent( $html );
79  $page->generate();
80?>
Note: See TracBrowser for help on using the browser.