-
Notifications
You must be signed in to change notification settings - Fork 0
/
tweet_get.php
29 lines (22 loc) · 1.08 KB
/
tweet_get.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
<?php
session_start();
if(!isset($_SESSION['username'])){
header('Location: index.php?error=1');
}
require_once('db.class.php');
$user_id = $_SESSION['user_id'];
$db_object = new database();
$link = $db_object->mysql_connect();
$sql = " SELECT DATE_FORMAT(t.inclusion_date, '%d %b %Y %T') AS format_inclusion_date, t.tweet, u.username FROM tweets AS t JOIN users AS u ON (t.user_id = u.id) WHERE user_id = $user_id OR user_id IN (SELECT user_follow_id FROM followers WHERE user_id = $user_id) ORDER BY inclusion_date DESC ";
$id_result = mysqli_query($link, $sql);
if($id_result){
while($user_data = mysqli_fetch_array($id_result, MYSQLI_ASSOC)){
echo '<a href="#" class="list-group-item">';
echo '<h4 class="list-group-item-heading">'.$user_data['username'].'<small> - '.$user_data['format_inclusion_date'].'</small></h4>';
echo '<p class="list-group-item-text">'.$user_data['tweet'].'</p>';
echo '</a>';
}
} else {
echo 'Erro na consulta de tweets.';
}
?>