generated from ToddSproull-WUSTL/V1-CSE330-Group-Template
-
Notifications
You must be signed in to change notification settings - Fork 6
/
comment-view.php
53 lines (41 loc) · 1.83 KB
/
comment-view.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
<?php require 'database.php';
session_start();?>
<html>
<head>
<title>My News Site</title>
<link href="news-site-styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container">
<div class="newstorysubmit">
<a href="index.php">Back to Main Page</a>
</div>
<h1>Comments</h1>
<?php
$mysqli = connectdb();
//select all comments associated with a specific newsid
$id = $_GET['id']; // get id through query string
// $allcomments = mysqli_query($mysqli,
// "SELECT comments.commentstext FROM comments
// JOIN stories ON (comments.commentid=stories.$id)");
$allcomments = mysqli_query($mysqli,
"SELECT * from comments");
echo "<ul>\n";
//this prints out all the comments!
while($data = mysqli_fetch_array($allcomments)){
echo $data['commentstext'];
?>
<!-- inserting php is like diving in and out of the water
while swimming, even if you break out of the tags for a bit
the same variables are still accessible in the same file -->
<a href="comment-edit.php?id=<?php echo $data['commentsid'];?>">Edit </a>
<a href="comment-delete.php?id=<?php echo $data['commentsid']; ?>">Delete</a>
<?php
echo "</ul>\n";
}
?>
<br>
<a href="comment-add.php">Add a Comment</a>
</div>
</body>
</html>