generated from ToddSproull-WUSTL/V1-CSE330-Group-Template
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.php
64 lines (50 loc) · 2.14 KB
/
index.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
<?php require 'database.php';
session_start();
$user = $_SESSION['username'];?>
<html>
<head>
<title>My News Site</title>
<link href="news-site-styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container">
<h1>Your News</h1>
<h3> You're logged in as <?php echo $user ?>!</h3>
<div class="news">
<?php
$mysqli = connectdb();
// $myquery = "SELECT * from stories WHERE userid=$user";
$myquery = "SELECT * from stories";
$allstories = mysqli_query($mysqli, $myquery);
echo "<ul>\n";
//this prints out all the stories!
while($data = mysqli_fetch_array($allstories)){
echo $data['newstitle'];
echo $data['newstext'];
if(isset($data['newslink'])) {
echo $data['newslink'];
}
?>
<!-- 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-view.php?id=<?php echo $data['newsid']; ?>">View Comments</a>
<a href="news-item-edit.php?id=<?php echo $data['newsid'];?>">Edit</a>
<a href="delete.php?id=<?php echo $data['newsid']; ?>">Delete</a>
<?php
echo "<ul>\n";
}
?>
</div>
<div class="newstorysubmit">
<a href="submitnews.php">Submit a New Story</a>
</div>
<!-- user can logout here -->
<form action="logout.php" method="POST">
<p>
<input type="submit" name="logout" value="logout" />
</p>
</form>
</div>
</body>
</html>