-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmy-bets.php
56 lines (51 loc) · 1.66 KB
/
my-bets.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
<?php
require_once "init.php";
require_once "helpers.php";
if (!isset($_SESSION["user"])) {
header("Location: /");
}
list($count_lots, $page_count) = compute_pagination_offset_and_limit(
$con,
"SELECT COUNT(id) AS 'count' FROM `bids` WHERE `user_id` = ?",
get_value_from_user_session("id")
);
$current_page = get_page_value();
$offset = get_offset_items($current_page, COUNT_ITEMS);
$current_id = get_escape_string($con, get_value_from_user_session("id"));
$result_bids = mysqli_query(
$con,
"SELECT
lots.name,
lots.link,
categories.name AS category,
lots.end_date,
bids.dt_add,
bids.price,
lots.description,
lots.id,
lots.winner_id,
users.users_info
FROM `bids` AS bids
JOIN `lots` AS lots ON lots.id = bids.lot_id
JOIN `categories` AS categories ON categories.id = lots.category_id
JOIN `users` AS users ON users.id = lots.author_id
WHERE `user_id` = " . $current_id . "
ORDER BY bids.dt_add DESC
LIMIT " . COUNT_ITEMS . " OFFSET " . $offset
);
get_error($con);
$bets = mysqli_fetch_all($result_bids, MYSQLI_ASSOC);
$content = include_template("bets.php", [
"bets" => $bets,
"user_id" => get_value_from_user_session("id"),
"count_lots" => $count_lots,
"page_count" => $page_count,
"current_page" => $current_page,
]);
$layout_content = include_template("layout.php", [
"content" => $content,
"title_page" => "Страница лота",
"user_name" => get_value_from_user_session("name"),
"categories" => $categories,
]);
print($layout_content);