-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex2.php
96 lines (86 loc) · 2.68 KB
/
index2.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
<?php
include('header.php');
?>
<body>
<br>
<br>
<div class="container">
<form class="form-horizontal" method="POST">
<div class="control-group">
<div class="controls">
<textarea rows="3" name="post_content" class="span6" placeholder="Whats on Your Mind"></textarea>
</div>
</div>
<div class="control-group">
<div class="controls">
<button name="post" type="submit" class="btn btn-info"><i class="icon-share"></i> Post</button>
</div>
</div>
<div class="control-group">
<div class="controls">
<table class="table table-bordered">
<thead>
</thead>
<tbody>
<?php
$query=mysql_query("select * Review")or die(mysql_error());
while($row=mysql_fetch_array($query)){
$id=$row['review_id'];
?>
<tr>
<td><?php echo $row['rtext']; ?></td>
<td width="50"><?php
$comment_query=mysql_query("select * from rtext where post_id='$id'")or die(mysql_error());
$count=mysql_num_rows($comment_query);
?>
<a href="#<?php echo $id; ?>" data-toggle="modal"><i class="icon-comments-alt"></i> <span class="badge badge-info"><?php echo $count; ?></span></a></td>
<td width="40"><a class="btn btn-danger" href="delete_post.php<?php echo '?id='.$id; ?>"><i class="icon-trash"></i></a></td>
</tr>
<!-- Modal -->
<div id="<?php echo $id; ?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header"> </div>
<div class="modal-body">
<!----comment -->
<form method="POST">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<textarea rows="3" name="comment_content" class="span6" placeholder="Your Comment Here"></textarea>
<br>
<br>
<button name="comment" type="submit" class="btn btn-info"><i class="icon-share"></i> Comment</button>
</form>
<br>
<br>
<?php $comment=mysql_query("select * from comment where post_id='$id'")or die(mysql_error());
while($comment_row=mysql_fetch_array($comment)){ ?>
<div class="alert alert-success"><?php echo $comment_row['content']; ?></div>
<?php } ?>
<!--- end comment -->
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
<?php } ?>
</tbody>
</table>
</div>
</div>
</form>
</div>
<?php
if(isset($_POST['post'])){
$post_content=$_POST['post_content'];
mysql_query("insert into post (content) values('$post_content')")or die(mysql_error());
header('location:index.php');
}
?>
<?php
if(isset($_POST['comment'])){
$comment_content=$_POST['comment_content'];
$post_id=$_POST['id'];
mysql_query("insert into comment (content,post_id) values('$comment_content',$post_id)")or die(mysql_error());
header('location:index.php');
}
?>
</body>
</html>