-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchat_list.php
68 lines (56 loc) · 2.31 KB
/
chat_list.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
session_start();
include('db.php');
error_reporting(E_ERROR | E_PARSE);
$select_nb_item = $bdd->prepare('SELECT id_from_user FROM cart WHERE id_from_user = ?');
$select_nb_item->execute(array($_SESSION['id']));
$nb_item_user = $select_nb_item->rowCount();
if ($_SESSION['id']) { ?>
<link rel="stylesheet" href="css/chat_list.css" type="text/css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>Chat - Silkroad</title>
<div>
<ul class="topnav">
<a href="index.php">
<img src="img/silkroad.png" class="logo_silkroad">
<h3 class="marque">Silkroad</h3>
</a> <?php
if(isset($_SESSION['id'])) { ?>
<li class="Tosell"><a href="sell.php">+ Add item</a></li>
<li class="Tosell2"><a href="edit.php">My items</a></li>
<li><a href="cart.php">Cart - <?php echo $nb_item_user; ?></a></li>
<li><a href="account.php">Account</a></li>
<?php
}
if(isset($_SESSION['id'])) {
$select_username = $bdd->prepare('SELECT * FROM user WHERE user_id = ?');
$select_username->execute(array($_SESSION['id']));
$user = $select_username->fetch();?>
<li><a href="index.php?deco">Logout</a> </li>
<?php
} else { ?>
<li><a href="login.php">Log in</a></li>
<li><a href="register.php">Register</a></li>
<?php
} ?>
</ul>
</div>
<div>
<?php
$select_chat = $bdd->prepare('SELECT * FROM discussions WHERE user_rec = ?');
$select_chat->execute(array($_SESSION['id']));
while ($chat = $select_chat->fetch()) {
$select_user = $bdd->prepare('SELECT * FROM user WHERE user_id = ?');
$select_user->execute(array($chat['user_env']));
$user = $select_user->fetch(); ?>
<div>
<a href="chat_with_owner.php?user_id=<?php echo $user['user_id']; ?>"><?php echo $user['username']; ?></a>
</div>
<br><br>
<?php
}
?>
</div>
<?php
}
?>