-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkomentar.php
112 lines (104 loc) · 2.9 KB
/
komentar.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
<link href="plugin/bootstrap.min.css" type="text/css" rel="stylesheet">
<link href="plugin/bootstrap-themes.css" type="text/css" rel="stylesheet">
<link rel="stylesheet" href="css/style.css" />
<?php
include 'function.php';
//fungsi untuk memperindah tulisan
include 'plugin/Parsedown.php';
$Parsedown = new Parsedown();
$id_anggota = $_SESSION['id_anggota'];
echo $_SESSION['id_anggota'];
if (isset($_POST['kirimkomentar']))
{
include 'koneksi.php';
$id_materi = $row ['id'];
$isi = mysql_real_escape_string ($_POST ['isikomentar']);
$waktu = time ();
$sql = "Insert into tbkomunikasi set
waktu = '$waktu',
id_materi = '$id_materi',
id_anggota = '$id_anggota',
isi = '$isi',
tipe = 2 ";
$_SESSION['kutipan']=null;
mysql_query($sql);
}
//jika ada aksi
if (isset($_GET['aksi']))
{
if ($_GET['aksi']=='hapuskomentar')
{
$sql_kom ="DELETE FROM tbkomunikasi WHERE id_kom='$_GET[id_kom]'";
mysql_query($sql_kom);
}
elseif ($_GET['aksi']== 'balaskomentar')
{
$sql_kom = "SELECT isi,id_anggota FROM tbkomunikasi WHERE id_kom='$_GET[id_kom]'";
$data_kom =mysql_query($sql_kom);
$datakutipan = mysql_fetch_assoc($data_kom);
$_SESSION['kutipan']= $datakutipan['isi'];
}
}//akhir aksi
else
{
$_SESSION['kutipan']=NULL;
}
?>
<table width="80%">
<tr>
<td>
<?php
if (!empty($_SESSION['kutipan']))
{
$balasan_anggota = $fungsi->idanggota_to_username($datakutipan['id_anggota'])['nama_lengkap'];
$isi =
"<blockquote>
Membalas komentar ". $balasan_anggota.
"<p>".$_SESSION['kutipan']."</p>".
"</blockquote>"
;
}
else
{
$isi = null;
}
?>
<form action="proses.php?id=<?php echo $row['id'] ?> " method="post">
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
<textarea data-provide="markdown" name="isikomentar" cols="40"><?php echo $isi; ?>
</textarea>
<input type="submit" name="kirimkomentar_materi" value="Kirim">
</form>
</tr>
</table>
<h3> Komentar </h3>
<?php
//daftar komentar
$id_materi = $_GET['id'];
$sql = "select * FROM tbkomunikasi WHERE id_materi= '$id_materi'";
$data = mysql_query($sql);
while ($row = mysql_fetch_assoc($data))
{
$namauser = $row['id_anggota'];
$isi = $Parsedown -> text ($row['isi']);
?>
<table width="100%" border="1">
<tr>
<td><?php echo $fungsi ->idanggota_to_username($namauser)["nama_lengkap"]; ?> <?php echo date('d-F-Y H:i:s A', $row['waktu'])?></td>
</tr>
<tr>
<td><?php echo $isi ?></td>
</tr>
<tr>
<td>Link : <a href="?id=<?php echo $_GET['id']; ?> &aksi=hapuskomentar&id_kom=<?php echo $row['id_kom']?>"> Hapus</a>
<a href="?id=<?php echo $_GET['id']; ?> &aksi=balaskomentar&id_kom=<?php echo $row['id_kom']?>"> Balas</a>
</td>
</tr>
</table>
<?php
}//akhir komentar
?>
<!-- Scripts-->
<script src="plugin/bootstrap.min.js"></script>
<script src="plugin/jquery-2.1.4.min.js"></script>
<script src="plugin/markdown.js"></script>