-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
63 lines (61 loc) · 1.83 KB
/
profile.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
<?php
include "session.php";
include "postupdate.php";
?>
<div class="container">
<div class="row">
<form class="col-lg-5 col-md-5 col-sm-5" method = "post" >
<h3 class="control-label" for="status">Post a new Update</h3>
<textarea class="form-control" style="resize :none;" id="status" name="status"></textarea>
<hr>
<input type="submit" id="btn-status" name = "btn-status" class="btn btn-success" onclick = "success()" value="Post">
<div id = "result"><?php echo $result;?></div>
</form>
<div class="col-lg-5 col-md-5 col-sm-5">
<h3 class="control-label" for="updates">Updates from Friends</h3>
<?php
$friendString = "";
$friendArray = array();
$selectFriendsQuery = mysql_query("SELECT friends FROM users WHERE username='$user'");
$friendRow = mysql_fetch_assoc($selectFriendsQuery);
$friendString = $friendRow['friends'];
if ($friendString != "") {
$friendArray = explode(",",$friendString);
}
$str = "";
$size = count($friendArray);
if($size != 0){
for ($i = 0; $i < $size; $i++) {
$value = $friendArray[$i];
$str = $str."SELECT time, username, updates from status WHERE username = '$value' UNION ";
}
$str = $str."SELECT time, username, updates from status WHERE username = '$value' ORDER BY time DESC";
//echo $str;
$getposts = mysql_query($str, $conn);
$count = 0;
while ($row = mysql_fetch_assoc($getposts)) {
$count++;
if($count > 20)
break;
?>
<div >
<h4> Update from <?php echo $row['username']; ?> <small> -- <?php echo date('Y-m-d H:i:s', strtotime($row['time'])); ?></small></h4>
<p>
<?php echo $row['updates']; ?>
</p>
</div>
<hr>
<?php
}
}
else{
?>
<p>No Updates yet!!</p>
<?php
}
?>
</div>
</div>
</div>
</body>
</html>