root/dev/common/search.php @ 206

Revision 206, 3.4 KB (checked in by ralle030583, 15 years ago)

-bugfix in Known Member mod corp detail
-deleted includes(db.php/class.page.php/class.killboard.php) which arent needed anymore everywhere cause of the include in the common/index.php

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