-
Notifications
You must be signed in to change notification settings - Fork 0
/
user-dashboard.php
170 lines (136 loc) · 6.95 KB
/
user-dashboard.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
<?php include "includes/db.php"; ?>
<?php include "includes/header.php"; ?>
<?php //include "admin/functions.php";?>
<?php session_start();?>
<?php include "includes/navigation.php"; ?>
<section class="dashboard section">
<!-- Container Start -->
<div class="container">
<!-- Row Start -->
<div class="row">
<div class="col-md-10 offset-md-1 col-lg-4 offset-lg-0">
<div class="sidebar">
<!-- User Widget -->
<div class="widget user-dashboard-profile">
<?php
if(isset($_SESSION['username'])) {
$username = $_SESSION['username'];
$query = "SELECT * FROM users WHERE username ='{$username}' ";
$select_user_profile_query = mysqli_query($connection, $query);
while ($row = mysqli_fetch_array($select_user_profile_query)) {
$user_id = $row['user_id'];
$user_email = $row['user_email'];
$user_image = $row['user_image'];
}
}
?>
<!-- User Image -->
<div class="profile-thumb">
<img src="images/<?php echo $user_image; ?>" alt="Image not Found" o class="rounded-circle">
</div>
<!-- User Name -->
<h5 class="text-center"><?php echo $username ?></h5>
<p class="text-center"><?php echo $user_email ?></p>
<a href="http://localhost:81/cms/account-profile.php" class="btn btn-main-sm">Edit Profile</a>
</div>
<!-- Dashboard Links -->
<div class="widget user-dashboard-menu">
<ul>
<li class="active">
<a href=""><i class="fa fa-user"></i> My Ads</a></li>
<li>
<a href="includes/logout.php"><i class="fa fa-cog"></i> Logout</a>
</li>
</ul>
</div>
</div>
</div>
<div class="col-md-10 offset-md-1 col-lg-8 offset-lg-0">
<!-- Recently Favorited -->
<div class="widget dashboard-container my-adslist">
<h3 class="widget-header">My Ads</h3>
<table class="table table-responsive product-dashboard-table">
<thead>
<tr>
<th>Image</th>
<th>Product Title</th>
<th class="text-center">Category</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<?php
if(isset($_GET['user'])){
$the_post_user=$_GET['user'];
}
$query = "SELECT * FROM posts WHERE (post_user= '{$the_post_user}') AND (post_status ='published')";
$select_all_posts_query = mysqli_query($connection, $query);
while ($row = mysqli_fetch_assoc($select_all_posts_query))
{
$post_id=$row['post_id'];
$post_title = $row['post_title'];
$post_author = $row['post_user'];
$post_date = $row['post_date'];
$post_image = $row['post_image'];
$post_category_id = $row['post_category_id'];
$post_price = $row['post_price'];
?>
<td class="product-thumb">
<img width="80px" height="auto" src="images/<?php echo $post_image; ?>" alt="image description"></td>
<td class="product-details">
<h3 class="title"><?php echo $post_title ?></h3>
<span><strong>Posted on: </strong><time><?php echo $post_date ?></time> </span>
<span><strong>Price: </strong><time><?php echo $post_price ?></time> </span>
</td>
<td class="product-category">
<span class="categories">
<?php
global $connection;
$query = "SELECT * FROM categories WHERE cat_id={$post_category_id}";
$select_categories_id = mysqli_query($connection,$query);
while($row = mysqli_fetch_assoc($select_categories_id)) {
$cat_id = $row['cat_id'];
$cat_title = $row['cat_title'];
echo "{$cat_title}";
}
?>
</span>
</td>
<td class="action" data-title="Action">
<div class="">
<ul class="list-inline justify-content-center">
<li class="list-inline-item">
<a data-toggle="tooltip" data-placement="top" title="Tooltip on top" class="view" href="post.php?p_id=<?php echo $post_id; ?>">
<i class="fa fa-eye"></i>
</a>
</li>
</ul>
</div>
</td>
<!-- <form method='post' action="">-->
<!-- <input type="hidden" name="post_id" value="--><?php //echo $post_id ?><!--">-->
<!-- --><?php
// echo '<td><input class="btn btn-danger" type="submit" name="delete" value="Delete"></td>';
// ?>
<!-- </form>-->
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
<!-- Row End -->
</div>
<!-- Container End -->
</section>
<?php
if(isset($_POST['delete'])){
$the_post_id= $_POST['post_id'];
$query ="DELETE FROM posts WHERE post_id= {$the_post_id} ";
$delete_query=mysqli_query($connection,$query);
redirect("../cms/account-profile.php");
}
?>