-
Notifications
You must be signed in to change notification settings - Fork 4
/
sidebar.php
101 lines (96 loc) · 3.86 KB
/
sidebar.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
<?php
$kategori_list = 'SELECT
kategori.kategori,
Count(berita.id_berita) AS jumlah,
kategori.id_kategori
FROM
berita
INNER JOIN kategori ON berita.id_kategori = kategori.id_kategori
GROUP BY
kategori.kategori,
kategori.id_kategori';
$list_kategori = $mysqli->query($kategori_list) or die($mysqli->error);
$terkini = 'SELECT
berita.id_berita,
berita.judul,
berita.gambar,
berita.tgl_posting,
berita.id_admin,
admin.nama_lengkap
FROM
berita
INNER JOIN admin ON berita.id_admin = admin.id_admin
ORDER BY
berita.tgl_posting DESC
LIMIT 0, 5
';
$populer = 'SELECT
berita.id_berita,
berita.judul,
berita.gambar,
berita.tgl_posting,
admin.nama_lengkap,
berita.id_admin,
berita.dilihat
FROM
berita
INNER JOIN admin ON berita.id_admin = admin.id_admin
ORDER BY
berita.dilihat DESC
LIMIT 0, 5
';
$list_terkini = $mysqli->query($terkini) or die ($mysqli->error);
$list_populer = $mysqli->query($populer) or die ($mysqli->error);
?>
<div class="col-md-4 sidebar">
<div class="sidebar-item kategori">
<h3 class="page-header">Kategori</h5>
<ul class="nav nav-pills nav-stacked nav-kat">
<?php while ($data_kat = $list_kategori->fetch_array()) { ?>
<?php if (isset($_GET['kat']) && $data_kat['id_kategori'] == $_GET['id'] ) { ?>
<li class="active">
<a href="<?php echo $base_url."kategori.php?id=".$data_kat['id_kategori']."&kat=".strtolower($data_kat['kategori']); ?>">
<?php echo $data_kat['kategori']; ?> <span class="badge pull-right"><?php echo $data_kat['jumlah'] ?></span></a>
</li>
<?php } else { ?>
<li>
<a href="<?php echo $base_url."kategori.php?id=".$data_kat['id_kategori']."&kat=".strtolower($data_kat['kategori']); ?>">
<?php echo $data_kat['kategori']; ?> <span class="badge pull-right"><?php echo $data_kat['jumlah'] ?></span></a>
</li>
<?php } ?>
<?php } ?>
</ul>
</div>
<div class="sidebar-item">
<h3 class="page-header">Populer</h3>
<ul class="news-list">
<?php while ($populer_list = $list_populer->fetch_array()) { ?>
<li>
<a <a href="<?php echo $base_url."detail.php?id=".$populer_list['id_berita']."&judul=".strtolower(str_replace(" ", "-", $populer_list['judul'])); ?>">
<img src="<?php echo $base_url."images/".$populer_list['gambar']; ?>" class="img-responsive wow fadeIn">
</a>
<p>Oleh: <a href="<?php echo $base_url."author.php?id=".$populer_list['id_admin']; ?>"><?php echo $populer_list['nama_lengkap']; ?></a> – <?php echo $populer_list['tgl_posting']; ?></p>
<a href="<?php echo $base_url."detail.php?id=".$populer_list['id_berita']."&judul=".strtolower(str_replace(" ", "-", $populer_list['judul'])); ?>">
<?php echo $populer_list['judul']; ?>
</a>
</li>
<?php } ?>
</ul>
</div>
<div class="sidebar-item">
<h3 class="page-header">Terkini</h3>
<ul class="news-list">
<?php while ($terkini_list = $list_terkini->fetch_array()) { ?>
<li>
<a href="<?php echo $base_url."detail.php?id=".$terkini_list['id_berita']."&judul=".strtolower(str_replace(" ", "-", $terkini_list['judul'])); ?>">
<img src="<?php echo $base_url."images/".$terkini_list['gambar']; ?>" class="img-responsive wow fadeIn">
</a>
<p>Oleh: <a href="<?php echo $base_url."author.php?id=".$terkini_list['id_admin']; ?>"><?php echo $terkini_list['nama_lengkap']; ?></a> – <?php echo $terkini_list['tgl_posting']; ?></p>
<a href="<?php echo $base_url."detail.php?id=".$terkini_list['id_berita']."&judul=".strtolower(str_replace(" ", "-", $terkini_list['judul'])); ?>">
<?php echo $terkini_list['judul']; ?>
</a>
</li>
<?php } ?>
</ul>
</div>
</div>