-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquoteData.php
More file actions
executable file
·82 lines (77 loc) · 3.97 KB
/
quoteData.php
File metadata and controls
executable file
·82 lines (77 loc) · 3.97 KB
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
<!-- For Lazy loading in quotes section! -->
<?php
include 'includes/db.php';
include './admin/functions.php';
if(!empty($_POST["id"])){
//Get last ID
$lastID = $_POST['id'];
//Limit on data display
$showLimit = 3;
//Get all rows except already displayed
$queryAll = query("SELECT * FROM quotes WHERE quote_id < ".$lastID." ORDER BY quote_id DESC");
confirmQuery($queryAll);
$rowAll = mysqli_fetch_assoc($queryAll);
$allNumRows = mysqli_num_rows($queryAll);
//Get rows by limit except already displayed
$query = "SELECT quote_id, quote_image, quote_author, quote_date, quote_category, quote_content FROM quotes WHERE quote_id < ".$lastID." ORDER BY quote_id DESC LIMIT ".$showLimit;
$count_query = query($query);
$count = mysqli_num_rows($count_query);
$quote_query = mysqli_prepare($connection, $query);
mysqli_stmt_execute($quote_query);
mysqli_stmt_store_result($quote_query);
mysqli_stmt_bind_result($quote_query, $quote_id, $quote_image, $quote_author, $quote_date, $quote_category, $quote_content);
if($count > 0){
while(mysqli_stmt_fetch($quote_query)){
// User Query
$query = "SELECT user_id, username, user_firstname, user_lastname, user_image FROM users WHERE username = ? ";
$stmt = mysqli_prepare($connection, $query);
mysqli_stmt_bind_param($stmt, 's', $quote_author);
mysqli_stmt_execute($stmt);
confirmQuery($stmt);
mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($stmt, $user_id, $username, $user_firstname, $user_lastname, $user_image);
mysqli_stmt_fetch($stmt);
$full_name = $user_firstname . " " . $user_lastname;
?>
<div class="card card-small mb-4">
<div class="card-header border-0 pb-0">
<div class="media post-author m-0 mb-2 align-self-center">
<img style="height: 40px; width: 40px;" src="<?php echo $baseURL; ?>/assets/images/profile/<?php echo $user_image; ?>" alt="<?php echo $post_author; ?>" class="img-fluid mr-3 mt-0 rounded-circle">
<div class="media-body align-self-center">
<div class="user-name">
<a href="<?php echo $baseURL; ?>/user_posts/<?php echo $username; ?>"><?php echo $full_name; ?></a>
</div>
<div class="date">
<small style="font-size: 12px;"><?php echo date('F j, Y', strtotime($quote_date)); ?></small>
</div>
</div>
</div>
</div>
<div class="card-body text-center p-0">
<a style="cursor: pointer;" href="<?php echo $baseURL; ?>/quote_page.php?q_id=<?php echo $quote_id; ?>"><img src="<?php echo $baseURL; ?>/assets/images/quote-images/<?php echo $quote_image; ?>" class="img-fluid quote-image" alt="<?php echo $quote_hashtags; ?>"></a>
</div>
<div class="card-footer border-0 quote-content">
<a href="<?php echo $baseURL; ?>/assets/images/quote-images/<?php echo $quote_image; ?>" style="color: #fff;" class="btn btn-md btn-success" download>
<i class="fas fa-download"></i>
</a>
<a href="<?php echo $baseURL; ?>/quote_page.php?q_id=<?php echo $quote_id; ?>" style="color: #fff;" class="btn btn-md btn-primary">
<i class="fa fa-arrow-right"></i>
</a>
<br>
<br>
<?php echo $quote_content; ?>
</div>
</div>
<?php } ?>
<?php if($allNumRows > $showLimit){ ?>
<div class="load-more text-center" lastID="<?php echo $quote_id; ?>" style="display: none;">
<img src="loading.gif"/>
</div>
<?php } else { ?>
<div class="load-more text-center" lastID="0">
</div>
<?php } } else { ?>
<div class="load-more text-center" lastID="0">
</div>
<?php }
} ?>