forked from hussien89aa/AndroidTutorialForBeginners
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTweetList.php
More file actions
41 lines (37 loc) · 1.34 KB
/
TweetList.php
File metadata and controls
41 lines (37 loc) · 1.34 KB
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
<?php
// 1- connect to db
require("DBInfo.php");
// define quesry //StartFrom
if ($usename=$_GET['op']==1) { // my following
$query="select * from user_tweets where user_id in (select following_user_id from following where user_id=". $_GET['user_id'] . ") or user_id=" . $_GET['user_id'] . " order by tweet_date DESC".
" LIMIT 20 OFFSET ". $_GET['StartFrom'] ; // $usename=$_GET['username'];
}
elseif ($usename=$_GET['op']==2) { // specific person post
$query="select * from user_tweets where user_id=" . $_GET['user_id'] . " order by tweet_date DESC" .
" LIMIT 20 OFFSET ". $_GET['StartFrom'] ; // $usename=$_GET['username'];
}
elseif ($usename=$_GET['op']==3) { // search post
$query="select * from user_tweets where tweet_text like '%" . $_GET['query'] .
"%' LIMIT 20 OFFSET ". $_GET['StartFrom'] ; // $usename=$_GET['username'];
}
$result= mysqli_query($connect, $query);
if(! $result)
{ die("Error in query");}
//get data from database
$output=array();
while($row= mysqli_fetch_assoc($result))
{
$output[]=$row; //$row['id']
}
if ($output) {
print( "{'msg':'has tweet'". ",'info':'". json_encode($output) ."'}");// this will print the output in json
}
else{
print("{'msg':'no tweet'}");
}
print(json_encode($output));// this will print the output in json
// 4 clear
mysqli_free_result($result);
//5- close connection
mysqli_close($connect);
?>