-
Notifications
You must be signed in to change notification settings - Fork 0
/
istock.php
125 lines (119 loc) · 3.15 KB
/
istock.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
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
<?php
session_start();
if(!$_SESSION["user"])
header('location: index.php');
$user=$_SESSION["user"];
$code=$_POST['code'];
$edate=$_POST['edate'];
$sdate=$_POST['sdate'];
?>
<!DOCTYPE html>
<html>
<head>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
text-align: left;
padding: 8px;
}
tr:nth-child(even) {background-color: #f2f2f2;}
tr:hover {background-color:#f5f5f5;}
</style>
</head>
<body>
<form method=post action=ichart.php target="_blank" >
<input type=hidden name=code value="<?php echo $code?>"><br>
<input type=hidden name=sdate value="<?php echo $sdate?>"><br>
<input type=hidden name=edate value = "<?php echo $edate ?>">
<input type="submit" name="formSubmit" value="get chart" />
</form>
<?php
display($code,$edate,$sdate);
function display($ticker,$edate,$sdate)
{
$connect=mysqli_connect('sql308.byethost11.com','b11_18001806','eshu@123');
if(mysqli_connect_errno())
die("couldnt connect to server");
mysqli_select_db($connect,"b11_18001806_dbms") or die('couldnt connect to the database');
$result = mysqli_query($connect,"SELECT * FROM $ticker");
if(!$result)
{
echo "<center><a href=form.php>click here to create record found for".$ticker."</a><br> no record foundfor ".$ticker."</center>";
return;
}
echo "<center><b><h1>".$ticker."</h1></b>";
echo "<table border='1'>
<tr>
<th>Date</th>";
if(isset($_POST['Open']) && $_POST['Open'] == 'Yes')
{
echo "<th>Open</th>";
}
if(isset($_POST['High']) && $_POST['High'] == 'Yes')
{
echo "<th>High</th>";
}
if(isset($_POST['Low']) && $_POST['Low'] == 'Yes')
{
echo "<th>Low</th>";
}
if(isset($_POST['Close']) && $_POST['Close'] == 'Yes')
{
echo "<th>Close</th>";
}
if(isset($_POST['Volume']) && $_POST['Volume'] == 'Yes')
{
echo "<th>Volume</th>";
}
if(isset($_POST['amount_change']) && $_POST['amount_change'] == 'Yes')
{
echo "<th>amount_change</th>";
}
if(isset($_POST['percent_change']) && $_POST['percent_change'] == 'Yes')
{
echo "<th>percent_change</th>";
}
echo "</tr>";
while($row = mysqli_fetch_array($result))
{
if($row['Date']>$sdate and $row['Date'] < $edate)
{
echo "<tr>";
echo "<td>" . $row['Date'] . "</td>";
if(isset($_POST['Open']) && $_POST['Open'] == 'Yes')
{
echo "<td>" . $row['Open'] . "</td>";
}
if(isset($_POST['High']) && $_POST['High'] == 'Yes')
{
echo "<td>" . $row['High'] . "</td>";
}
if(isset($_POST['Low']) && $_POST['Low'] == 'Yes')
{
echo "<td>" . $row['Low'] . "</td>";
}
if(isset($_POST['Close']) && $_POST['Close'] == 'Yes')
{
echo "<td>" . $row['Close'] . "</td>";
}
if(isset($_POST['Volume']) && $_POST['Volume'] == 'Yes')
{
echo "<td>" . $row['Volume'] . "</td>";
}
if(isset($_POST['amount_change']) && $_POST['amount_change'] == 'Yes')
{
echo "<td>" . $row['amount_change'] . "</td>";
}
if(isset($_POST['percent_change']) && $_POST['percent_change'] == 'Yes')
{
echo "<td>" . $row['percent_change'] . "</td>";
}
echo "</tr>";
}
}
echo "</table></center>";
}
?>