-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfooterFunctions.php
More file actions
60 lines (54 loc) · 2.74 KB
/
footerFunctions.php
File metadata and controls
60 lines (54 loc) · 2.74 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
<?php
function latest_posts()
{
global $connection;
$articleQuery = "SELECT `articles`.`id`,`articles`.`title`,`users`.`first_name`,`users`.`last_name`,`articles`.`published_date`,`articles`.`image`
FROM `articles`
LEFT JOIN `users` ON `users`.`id` = `articles`.`user_id`
LEFT JOIN `category` ON `category`.`id` = `articles`.`category_id`
ORDER BY `articles`.`id` DESC LIMIT 3;";
$articles = mysqli_query($connection, $articleQuery);
while ($row = mysqli_fetch_assoc($articles)) {
$id = $row['id'];
$title = $row['title'];
$date = $row['published_date'];
$img = $row['image'];
echo "<div class='row pb-3'>
<div class='col-5 align-self-center'>
<a href='single.php?p_id={$id}'class='footer_post pb-4'><img src='{$img}' alt='img' style = 'object-fit: cover;' class='fh5co_most_trading' /></a>
</div>
<div class='col-7 paddding'>
<div class='most_fh5co_treding_font'><a href='single.php?p_id={$id}'class='footer_post pb-4'> {$title} </a> </div>
<div class='most_fh5co_treding_font_123'> {$date} </div>
</div>
</div>";
}
}
function categories(){
global $connection;
$query = "SELECT * FROM category";
$select_categories = mysqli_query($connection,$query);
//confirmQuery($select_categories);
while($row = mysqli_fetch_assoc($select_categories )) {
$cat_id = $row['id'];
$cat_name = $row['category_name'];
echo "<ul class='footer_menu'><li><a href='categories.php?cat_id=$cat_id' class=''><i class='fa fa-angle-right'></i> $cat_name</a></li></ul>";
}
}
function mostViewedPosts(){
global $connection;
$most_viewed_posts_query = "SELECT `articles`.`id`,`articles`.`title`,`articles`.`published_date`,`articles`.`image`
FROM `articles`
INNER JOIN `count_page_views` on `articles`.`id` = `count_page_views`.`article_id`
GROUP by `articles`.`id`
ORDER by COUNT(`count_page_views`.`article_id`) desc limit 4";
$execute_query = mysqli_query($connection, $most_viewed_posts_query);
while ($rows = mysqli_fetch_assoc($execute_query)) {
$id = $rows['id'];
$title = $rows['title'];
$date = $rows['published_date'];
echo "<div class='footer_makes_sub_font'> {$date}</div>
<a href='single.php?p_id={$id}' class='footer_post pb-4'>{$title}</a>";
}
}
?>