-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay_most_profitable.php
68 lines (62 loc) · 2.14 KB
/
display_most_profitable.php
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
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*
*
*
* localhost/Eve_industry_data/display_most_profitable.php
*/
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "test";
$sellVol = (int) $_GET["sellVol"];
$buyVol = (int) $_GET["buyVol"];
$delta = (int) $_GET["delta"];
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully" . PHP_EOL;
} catch (PDOException $e) {
echo "Connection failed: " . $e->getMessage() . PHP_EOL;
}
$query = $conn->prepare(
"SELECT i.typeID, i.typeName, j.typeID, j.sellVolume, j.buyVolume, j.max, j.min, j.orders, j.profit, j.delta "
. "FROM invtypes AS i "
. "INNER JOIN jitamarket AS J ON j.typeID = i.typeID "
. "WHERE j.buyVolume > {$buyVol} AND j.sellVolume > {$sellVol} "
. "AND j.delta > {$delta} "
. "AND i.marketGroupID NOT IN (SELECT `marketGroupID` FROM `invmarketgroups` "
. "WHERE `parentGroupID` = '19' ORDER BY `marketGroupName`) " //market group 19 is trade goods so removing it
. "ORDER BY j.profit DESC Limit 0,30");
$query->execute();
$profitable_items = $query->fetchAll();
//echo "<pre>" . print_r($profitable_items) . "</pre>";
echo '<table>
<tr>
<td>Item Name</td>
<td>Sell Volume</td>
<td>Buy Volume</td>
<td>Max Buy price</td>
<td>Min Sell price</td>
<td>Delta</td>
<td>Orders</td>
<td>Total Potential Profit</td>
</tr>';
foreach ($profitable_items as $item) {
echo "<tr>"
. "<td>{$item['typeName']}</td>"
. "<td>{$item['sellVolume']}</td>"
. "<td>{$item['buyVolume']}</td>"
. "<td>{$item['max']}</td>"
. "<td>{$item['min']}</td>"
. "<td>{$item['delta']}</td>"
. "<td>{$item['orders']}</td>"
. "<td>{$item['profit']}</td>"
. "</tr>";
}
echo "</table>";
?>