-
Notifications
You must be signed in to change notification settings - Fork 0
/
Watchlist.php
495 lines (431 loc) · 16.7 KB
/
Watchlist.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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>FinFlexx</title>
<link rel="stylesheet" href="./css/style.css" />
<!-- Boxicons CSS -->
<link flex href="https://unpkg.com/[email protected]/css/boxicons.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" />
<script src="./js/script.js" defer></script>
<link type="image" rel="icon" href="./img/finflexx.png" />
<style>
.box {
background-color: #0e1117;
display: flex;
align-items: center;
justify-content: center;
padding-left: 150px;
padding-bottom: 30px;
}
/* Style for the table */
table {
width: 80%;
padding-left: 95px;
}
/* Style for table cells */
td {
text-align: center;
padding-bottom: 100px;
padding-left: 40px;
padding-right: 40px;
}
/* Style for images */
img {
width: 100px;
height: 100px;
background-color: #0e1117;
cursor: pointer;
}
.head {
font-size: 40px;
color: #fff;
font-weight: 1000;
padding-left: 700px;
padding-bottom: 55px;
}
input.checkbox {
cursor: pointer;
width: 15px;
height: 15px;
color: #0e1117;
}
.submit {
position: absolute;
top: 1725px;
left: 740px;
border-radius: 20px;
font-size: 20px;
background-color: #0e1117;
border: 2px solid #fff;
cursor: pointer;
color: #fff;
font-weight: 650;
padding: 10px 10px 10px 10px;
}
.avatar {
width: 45px;
/* Adjust size as needed */
height: 45px;
/* Adjust size as needed */
border-radius: 50%;
background-color: #02a350;
/* You can change the background color */
display: flex;
justify-content: center;
align-items: center;
font-size: 28px;
/* Adjust font size as needed */
font-weight: 500;
color: #fff;
/* You can change the text color */
margin-right: 5px;
/* Adjust margin as needed */
}
.random-color-box {
width: 200px;
height: 200px;
background-color: #00c760;
/* Initial color */
}
.submit2 {
position: absolute;
left: 700px;
border-radius: 20px;
font-size: 20px;
background-color: #0e1117;
border: 2px solid #fff;
cursor: pointer;
color: #fff;
font-weight: 650;
padding: 10px 10px 10px 10px;
text-decoration: none;
/* Add this line to remove underline */
}
</style>
</head>
<body>
<nav class="sidebar locked">
<div class="logo_items flex">
<span class="nav_image">
<img src="./img/finflexx.png" alt="logo_img" />
</span>
<span class="logo_name">FinFlexx</span>
<i class="bx bx-lock-alt" id="lock-icon" title="Unlock Sidebar"></i>
<i class="bx bx-x" id="sidebar-close"></i>
</div>
<div class="menu_container">
<div class="menu_items">
<ul class="menu_item">
<div class="menu_title flex">
<span class="title">Dashboard</span>
<span class="line"></span>
</div>
<li class="item">
<a href="./index2.html" class="link flex">
<i class="bx bx-home-alt"></i>
<span>Home</span>
</a>
</li>
<li class="item">
<a href="./news2.html" class="link flex">
<i class='bx bx-news'></i>
<span>News & Blogs</span>
</a>
</li>
</ul>
<ul class="menu_item">
<div class="menu_title flex">
<span class="title">Stocks</span>
<span class="line"></span>
</div>
<li class="item">
<a href="#" class="link flex">
<i class='bx bx-heart'></i>
<span>Watchlists</span>
</a>
</li>
<li class="item">
<a href="./explore2.html" class="link flex">
<i class='bx bx-candles'></i>
<span>Explore Stocks</span>
</a>
</li>
</ul>
<ul class="menu_item">
<div class="menu_title flex">
<span class="title">Services</span>
<span class="line"></span>
</div>
<li class="item">
<a href="./predict.html" class="link flex">
<i class='bx bx-rupee'></i>
<span>Price Prediction</span>
</a>
</li>
</ul>
<ul class="menu_item">
<div class="menu_title flex">
<span class="title">Account</span>
<span class="line"></span>
</div>
<li class="item">
<a href="./details.php" class="link flex">
<i class='bx bxs-user-detail'></i>
<span>Details</span>
</a>
</li>
<li class="item">
<a href="./index.html" class="link flex">
<i class='bx bxs-exit'></i>
<span>Log Out</span>
</a>
</li>
</ul>
</div>
<div class="sidebar_profile flex">
<span class="nav_image1">
<div id="avatarContainer"></div>
</span>
<div class="data_text">
<span class="name" id="username"></span>
<!--<span class="email">[email protected]</span>-->
</div>
</div>
</div>
</nav>
<!-- Navbar -->
<nav class="navbar">
<i class="bx bx-menu" id="sidebar-open"></i>
<div class="wrapper">
<div class="search-input">
<a href="" target="_blank" hidden></a>
<input type="text" placeholder="Search for Stocks..." class="bar search_box">
<div class="autocom-box">
<!-- here list are inserted from javascript -->
</div>
<div class="icon"><i class="fas fa-search"></i></div>
</div>
</div>
</nav>
<Section id="welcome_Sec">
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container">
<div class="tradingview-widget-container__widget"></div>
<script type="text/javascript"
src="https://s3.tradingview.com/external-embedding/embed-widget-ticker-tape.js" async>
{
"symbols": [
{
"description": "",
"proName": "NASDAQ:TSLA"
},
{
"description": "",
"proName": "NASDAQ:AAPL"
},
{
"description": "",
"proName": "NASDAQ:AMZN"
},
{
"description": "",
"proName": "NASDAQ:GOOGL"
},
{
"description": "",
"proName": "NASDAQ:MSFT"
}
],
"showSymbolLogo": true,
"isTransparent": false,
"displayMode": "adaptive",
"colorTheme": "dark",
"locale": "en"
}
</script>
</div>
<!-- TradingView Widget END -->
</Section>
<br><br><br>
<h1 class="head">Your Watchlist</h1><br>
<html>
<head>
<style>
table {
width: 50%;
border-collapse: collapse;
margin-left: 450px;
color: #fff;
/* Aligning table to center */
}
table,
th,
td {
border: 3px solid #fff;
padding: 8px;
text-align: center;
}
th {
background-color: transparent;
}
/* Adding styles for the message */
.message {
margin: 0 auto;
/* Centering the message */
text-align: center;
/* Centering the text */
font-size: 20px;
/* Changing font size */
color: #00c760;
/* Changing font color */
padding-left: 170px;
}
input[type="checkbox"] {
cursor: pointer;
}
</style>
</head>
<body>
<?php
// Database connection parameters
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "loginpage";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Query to fetch the last logged in user
$sql_login = "SELECT name FROM login ORDER BY id DESC LIMIT 1";
$result_login = $conn->query($sql_login);
if ($result_login->num_rows > 0) {
// Fetch the username of the last logged in user
$row_login = $result_login->fetch_assoc();
$last_logged_in_user = $row_login["name"];
// Defining an associative array for stock names and their full names
$stock_names_full_names = array(
"AAPL" => "Apple Inc.",
"GOOGL" => "Google Inc.",
"MSFT" => "Microsoft Corporation",
"TSLA" => "Tesla Inc.",
"AMZN" => "Amazon Inc.",
"RELIANCE.NS" => "Reliance Industries Ltd.",
"TCS.NS" => "Tata Consulting Services",
"INFY.NS" => "Infosys Ltd.",
"SBIN.NS" => "State Bank of India",
"HDFCBANK.NS" => "HDFC Bank Ltd."
// Add more stocks and their full names as needed
);
// Query to fetch rows from the watchlist table for the last logged in user
$sql_watchlist = "SELECT * FROM watchlist WHERE name = '$last_logged_in_user'";
$result_watchlist = $conn->query($sql_watchlist);
if ($result_watchlist->num_rows > 0) {
// Display the data in a tabular format using HTML
echo "<form method='post' action='./php/remove_from_watchlist.php'>";
echo "<table>
<tr>
<th>S. No.</th>
<th>Logo</th>
<th>Symbol</th>
<th>Stock Name</th>
<th>Select</th>
</tr>";
// Variable to keep track of serial number
$serial_number = 1;
while ($row_watchlist = $result_watchlist->fetch_assoc()) {
// Get the full name from the associative array
$full_name = isset($stock_names_full_names[$row_watchlist["stock_name"]]) ? $stock_names_full_names[$row_watchlist["stock_name"]] : "Unknown";
echo "<tr>";
echo "<td>" . $serial_number . "</td>";
// Display image
$image_path = "HOME/" . strtolower($row_watchlist["stock_name"]) . ".png"; // Assuming the image names are in lowercase
echo "<td><img src='$image_path' alt='$full_name'></td>";
echo "<td>" . $row_watchlist["stock_name"] . "</td>";
echo "<td>" . $full_name . "</td>";
// Add checkbox column
echo "<td><input type='checkbox' name='selected[]' value='" . $row_watchlist["stock_name"] . "'></td>";
echo "</tr>";
// Increment serial number
$serial_number++;
}
echo "</table>";
echo "<br><br>";
echo "<input type='submit' value='Remove from Watchlist' class='submit2'>";
echo "</form>";
echo "<br><br>";
echo "<br><br>";
echo "<br><br>";
echo "<br><br>";
} else {
// Display message if no data found in watchlist for the user
echo "<p class='message'>There are currently no Stocks in your Watchlist !</p>";
echo "<br>";
echo "<p class='message'>Please Redirect to the Home Page and Add Stocks to your Watchlist.</p>";
echo "<br><br>";
echo "<br><br>";
echo "<br><br>";
echo "<br><br>";
echo "<br><br>";
echo "<br><br>";
echo "<br><br>";
}
} else {
// Display message if no users logged in
echo "<p class='message'>No users logged in.</p>";
}
// Close connection
$conn->close();
?>
</body>
</html>
<footer>
<p class="copyright">
Copyright
©
2024 FinFlexx</p>
</footer>
<script>
// Function to format the user's name
function formatUserName(name) {
// Split the name into an array of words
var words = name.toLowerCase().split(' ');
// Capitalize the first letter of each word
for (var i = 0; i < words.length; i++) {
words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1);
}
// Join the words back into a single string and return
return words.join(' ');
}
// Function to fetch user information from the server
function fetchUserInfo() {
// Make an AJAX request to fetch user information
var xhr = new XMLHttpRequest();
xhr.open('GET', './php/get_user_info.php', true); // Assuming your PHP file to retrieve user info is named get_user_info.php
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var userInfo = JSON.parse(xhr.responseText);
// Format the user's name
var formattedName = formatUserName(userInfo.name);
// Update the HTML content with the formatted name
document.getElementById('username').innerText = formattedName;
// Create and display the avatar using the initial of the user's name
var avatar = document.createElement('div');
avatar.className = 'avatar';
avatar.innerText = formattedName.charAt(0).toUpperCase(); // Display the initial of the user's name
document.getElementById('avatarContainer').appendChild(avatar);
}
};
xhr.send();
}
// Call the function when the page loads
window.onload = fetchUserInfo;
</script>
<script src="./js/search_script2.js"></script>
</body>
</html>