-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunit.php
More file actions
153 lines (151 loc) · 5.44 KB
/
unit.php
File metadata and controls
153 lines (151 loc) · 5.44 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
include('./inc/connect.inc');
include('./inc/header.inc');
$UnitID = addslashes($_GET['ID']);
//Query for general unit information
$result = mysqli_query($connect,"SELECT * FROM Units INNER JOIN Releases
ON Units.Release = Releases.Release
WHERE UnitID = " . $UnitID);
//Query for unit's attack information
$attackQuery = mysqli_query($connect,"SELECT * FROM Unit_Attack,Attacks
WHERE UnitID = " . $UnitID .
" AND Attack = AttackName ORDER BY Priority");
//Query for unit's abilities
$abilityQuery = mysqli_query($connect,'SELECT * FROM Abilities
WHERE AbilityName IN
(SELECT AbilityName FROM Unit_Abilities
WHERE UnitID = ' . $UnitID . ')');
//Query for unit's faction to determine background color
$factionQuery = mysqli_query($connect,'SELECT Alliance FROM Factions
WHERE Faction = (SELECT Faction FROM Units
WHERE UnitID = ' . $UnitID . ')');
$faction = mysqli_fetch_array($factionQuery);
$row = mysqli_fetch_array($result);
//General unit stats
echo('<table width="450px"><tr><td colspan="5" class="img">
<img src="./images/');
//Check if image exists, if not, use default 'noimage.jpg'
if(file_exists('./images/' . $row['Release'] . '/' . $row['SetNumber']
. '.jpg'))
{
echo($row['Release'] . '/' . $row['SetNumber']);
} else {
echo('noimage');
}
echo('.jpg" /></td></tr>
<tr><td colspan="4" class="inv">' . $row['Name'] .
'</td><td width="75px" rowspan="2" class="points ' .
$faction['Alliance'] . '">' . $row['Points'] .
'</td></tr><tr><td rowspan="2" class="alt3" style="width:50px">
<img src="./images/faction/' .
$row['Faction'] . '-sm.png" alt="' . $row['Faction'] . '" />' .
'</td><td colspan="3" class="small ' . $faction['Alliance'] .
'"><span class="left">' . $row['Type']);
if($row['Subtype'])
{
echo(' - ' . $row['Subtype']);
}
echo('</span><span class="right">' . $row['Year'] . '</span>' .
'</td></tr><tr><td class="small inv"> Speed - ');
if($row['Speed'] != NULL)
{
echo($row['Speed']);
} else if($row['Type'] = 'Aircraft') {
echo('A');
}
echo('</td><td class="small inv" width="50px">');
if($row['Flagship'])
{
echo('<img src="./images/symbols/Flagship.png" alt="Flagship" /> '
. $row['Flagship']);
}
echo('</td><td class="small inv" width="50px">');
if($row['Carrier'])
{
for($i = $row['Carrier']; $i > 0; $i--)
{
echo('<img src="./images/symbols/Carrier.png" alt="Carrier" />');
}
}
echo('</td><td class="alt3" /></tr></table>');
//Attack stats
echo('<table width="450px"><tr>
<td class="small inv center" width="75px">Attack</td>
<td class="small inv center" width="50px">0</td>
<td class="small inv center" width="50px">1</td>
<td class="small inv center" width="50px">2</td>
<td class="small inv center" width="50px">3</td>
<td class="alt3" /></tr>');
while($attack = mysqli_fetch_array($attackQuery))
{
//Check for Main Gunnery symbol, set the symbol name
switch($attack['Attack'])
{
case "Gunnery1":
$atkImg = $attack['Attack'] . '-' . $row['Type'];
break;
default:
$atkImg = $attack['Attack'];
}
echo('<tr><td class="inv center"><img src="./images/attacks/' . $atkImg .
'.png" /></td><td class="atk">' . $attack['Range0'] .
'</td><td class="atk">');
if($attack['Range1'] != NULL)
{
echo($attack['Range1'] . '</td><td class="atk">');
} else {
echo('-' . '</td><td class="atk">');
}
if($attack['Range2'] != NULL)
{
echo($attack['Range2'] . '</td><td class="atk">');
} else {
echo('-' . '</td><td class="atk">');
}
if($attack['Range3'] != NULL)
{
echo($attack['Range3'] . '</td><td width="75px" class="alt3" /></tr>');
} else {
echo('-' . '</td><td class="alt3" /></tr>');
}
}
//Armor stats
echo('</table><table width="450px"><tr><td class="inv"> Armor </td>
<td class="center">' . $row['Armor'] .
'</td><td class="inv"> Vital Armor </td>
<td class="center">' . $row['VitalArmor'] .
'</td><td class="inv"> Hull Points </td>
<td class="center">' . $row['HullPoints'] .
'</td></tr></table>');
//Abilties
echo('<table width="450px">');
if($row['Flagship'] != NULL)
{
echo('<tr><td class="alt3 small">Flagship ' . $row['Flagship']);
}
if($row['Carrier'] != NULL)
{
echo('<tr><td class="alt3 small">Base ' . $row['Carrier'] .
' Squadron(s)');
}
while($ability = mysqli_fetch_array($abilityQuery))
{
echo('<tr><td class="alt2 small">' . $ability['AbilityName'] .
' -</td></tr><tr><td class="alt3 ability">' .
$ability['AbilityText'] . '</td></tr>');
}
echo('<tr><td class="small inv">' . $row['Release'] . ' - ' .
$row['SetNumber'] . '/' . $row['NumberOfUnits'] . ' - ' .
$row['Rarity'] . '</td></tr></table>');
if($row['Lore'] != NULL)
{
echo('<table width="450px"><tr><td class="alt2 small">Lore -</td></tr>
<td class="alt3 ability">' . $row['Lore'] . '</td></tr></table>');
}
if($row['Notes'] != NULL)
{
echo('<table width="450px"><tr><td class="alt2 small">Notes -</td></tr>
<td class="alt3 ability">' . $row['Notes'] . '</td></tr></table>');
}
include("./inc/footer.inc");
?>