Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 只从新闻提要中的数据库获取我自己的帖子一次_Php - Fatal编程技术网

Php 只从新闻提要中的数据库获取我自己的帖子一次

Php 只从新闻提要中的数据库获取我自己的帖子一次,php,Php,我创建了一个新闻提要系统,所以当我提取跟踪我或我的用户的帖子时。我也得到了我的多个职位 例如: #Friends Requests table #(My ID is : 1) Id|sender|receiver|statu ---------------------------- 1 |1 |2 |accepted ---------------------------- 2 |3 |1 |accepted ----------------------

我创建了一个新闻提要系统,所以当我提取跟踪我或我的用户的帖子时。我也得到了我的多个职位

例如:

#Friends Requests table
#(My ID is : 1)

Id|sender|receiver|statu
----------------------------
1 |1     |2       |accepted
----------------------------
2 |3     |1       |accepted
----------------------------
获取邮政编码

$getFollowers = $PDO->query(" SELECT * FROM friends_requests WHERE (sender='$myID' OR receiver='$myID') AND statu='accepted' ");

while($getFollowersData = $getFollowers->fetch()){

  $getPosts = $PDO->query("SELECT * FROM posts WHERE publisherID=".$getFollowersData['sender']." OR publisherID=".$getFollowersData['receiver']);

while($showPosts = $getPosts->fetch()){
//SHOW ALL POSTS
}
}


那么,伙计们,除了只发一次我自己的帖子之外,还有其他方法可以做同样的事情吗?

一个简单的小组不能解决你的问题吗?虽然我不确定您的posts表是什么样子的,甚至像这样存储重复的posts也是理想的

$getPosts = $PDO->query("SELECT * FROM posts WHERE publisherID=".$getFollowersData['sender']." OR publisherID=".$getFollowersData['receiver']." GROUP BY Id;";