你好我米试图从数据库中我通知系统得到数组名。这样我已经采取了3个条件。并在第二和第三我需要数组中的名称,任何人都可以帮助我与代码。也是在$结果查询我不是能够避免同一用户的结果即我想约翰对我的身份评论两次,然后只有一个结果,应选择,我用不同的针对,但没有成功。在阵列越来越名字通知系统
所以基本上有两种porblems
- 使用阵列
- 避免相同的用户名的结果在用于阵列中选择的用户名从数据库中获取一个以上的名称。
谁能帮助,它是一个大的模块卡非常糟糕。感谢
<?php
include_once("includes/connection.php");
$result = mysql_query("SELECT distinct * from notification inner join users_profile on notification.owner_user_id=users_profile.uid where notification.user_id=3 and notification.user_id!=notification.owner_user_id order by notification.time_stamp Desc");
while ($row=mysql_fetch_array($result)) {
$nfname[]=$row["fname"];
$npicid[]=$row["profile_pic"];
$sql2 =mysql_query("SELECT COUNT(type_id) FROM notification where type_id='wall_comments' and user_id='3' and is_seen='0'");
while($row2=mysql_fetch_array($sql2)) {
$req_pending=$row2['COUNT(type_id)'];
$req_pending1=$row2['COUNT(type_id)']-3;
if ($req_pending==1) {
$result="$fname shared view on your Status Update";
}
elseif ($req_pending==3) {
$result="$nfname shared views on your Status Update";
}
else {
$result="$nfname and $req_pending1 shared their views on your Status Update";
}
}
}
?>
如果您的表中有日期时间或时间戳字段,则distinct会将所有多个用户重复使用两次,因为您正在选择'*',并且每个记录的日期时间都不相同。另外,你还没有真正解释你在获取数组中的名字时面临的问题。看起来你已经用'$ nfname [] = $ row [“fname”];' – sadmicrowave 2012-01-12 15:38:06
已经实现了这个答案,谢谢你的回复,第一是任何方式,我只能从两个记录中的两个记录中获得一个名字同名第二我得到警告:mysql_fetch_array()期望参数1是资源,字符串给出在C:\ wamp \ www \ mihubs \ test.php上使用数组时的第5行错误 – 2012-01-12 15:46:28