Php 如何在多值条件下选择同一表?
以下是表Php 如何在多值条件下选择同一表?,php,mysql,sql,while-loop,Php,Mysql,Sql,While Loop,以下是表活动的详细信息 id| uid | acid | type |topic 1 | 01 | 05 | followu |0 2 | 01 | 06 | followu |0 3 | 06 | 23 | asked |5 4 | 06 | 23 | answered|0 5 | 05 | 96 | comments|0 6 | 01 |
活动的详细信息
id| uid | acid | type |topic
1 | 01 | 05 | followu |0
2 | 01 | 06 | followu |0
3 | 06 | 23 | asked |5
4 | 06 | 23 | answered|0
5 | 05 | 96 | comments|0
6 | 01 | 5 | ftopic |0
7 | 01 | 23 | fasked |0
8 | 01 | 58 | asked |7
9 | 37 | 58 | answered|0
这是描述
- followu=UserID(
)01在UserID(uid
)05-->[对于id=1]acid
- asked=
askeing(Post)something,Post id=23-->[for] id=3]UserID 06
- 已回答=
为用户ID 06
回答(发布)了一些东西,这主要是被问34的ID(显示ID=3)-->[对于ID=4]acid=34
- comments=User ID 05评论(Post)某物,Post ID=06-->[对于ID=5]
- fasked=
在一篇被问到的帖子[被问的类型]之后声明,而被问到的(UserID 01
)=23(被问到的acid
在id=3中)-->[对于id=7]askedid(acid)
Userid[01]
在Userid
05,06之后userid
05,06中看到一些活动Userid[01]
在id=7
和indid=9
中紧跟着一个askedid=58
另一个userid 37
回答了这个问题id=9中的userid(uid)37
回答了一篇文章,其中acid=58,这与id=8
askedid(acid
)=58有关。因此Userid(uid)也将获得这个id=9
feed。与往常一样,主题[type=ftopic]后面的用户ID[01]在这里topicid[acid=5]
所以任何被询问的类型行都将与acid
匹配,后者等于topicid[acid=5]
,并且这些行也必须在提要列表中
所以我试着
$query = "select * from `activitis` where (`type`='fasked' OR `type`='fuser' OR `type`='ftopic') and `uid`='01'");
;
$result = mysql_query($query);
if($result){
while($row = mysql_fetch_array($result))
{
////// Here we can get the following `userid` `topicid` and `askedid` Now we can select `activities`table like, for `userid` selecting `uid` AND for `topicid` and `askedid` selecting `acid`
///// But i also wanted the activites of my following userid askedid and topicid related But if I loop again in this Loop i have to loop for separated type `fasked` `fuser` and `ftopic` But i want result like `order by` `id` and mixed type feed. Just like facebook newsfeed its showing mixed type of feed.
}
}
对不起,读了几遍之后,我真的不明白你的问题。你能澄清一下吗?我在where子句中也注意到了这一点:uid
='01'uid是字符数据类型还是数字类型?很抱歉,我没有注意到实际上uid是字符数据类型字符或数字类型并不是事实。太短的问题:你可以看到一个表格活动:现在用php制作一个提要列表[比如facebook新闻提要]谢谢你澄清这一点,但不幸的是,我仍然不太理解你的问题:(也许除了我以外的人会到这里来为你回答是的,谢谢..如果我想这样描述的话“我有一个网站,人们互相关注,关注许多话题,在“话题”下提问。人们回答问题,关注问题,喜欢问题,很多人发表评论,喜欢并投票表决答案“但所有内容都保存在一个名为activates的表中。现在,我如何为用户分离提要取决于他们关注的用户、主题和问题……这将非常清楚,但很快我将获得否决票并保留。有人会说,请阅读我们的条款“您尝试了吗?LOLSo…您正在使堆栈溢出?”/