我遇到这样的问题: 循环显示用户帖子及其朋友的内容:
$newsfeed_post_data_query = @mysqli_query($db,"SELECT * FROM giccos_status WHERE user_id='$user_logged_userid' OR (user_id='$newsfeed_post_data_friend_guyid' AND (privacy='friend' OR privacy='friendoffriend' OR privacy='public')) ORDER BY status_id DESC LIMIT 10");
while($newsfeed_post_data = mysqli_fetch_array($newsfeed_post_data_query)){
// Get content of $newsfeed_post_data.
}
但问题是我需要通过以下方式获取他们朋友的身份:
$newsfeed_post_data_friend_query = @mysqli_query($db,"SELECT * FROM giccos_friend WHERE user_id='$user_logged_userid'");
while($newsfeed_post_data_friend = mysqli_fetch_array($newsfeed_post_data_friend_query)){
$newsfeed_post_data_friend_guyid = $newsfeed_post_data_friend['guy_id']; // <-- This is the number I need to get to fit in the loop.
}
如何在没有错误的情况下写信?
如果我这样写,我的第二个循环将会纠正。但它已被重复多次(取决于从第一个循环返回的值)并且排列错误。
$newsfeed_post_data_friend_query = @mysqli_query($db,"SELECT * FROM giccos_friend WHERE user_id='$user_logged_userid'");
while($newsfeed_post_data_friend = mysqli_fetch_array($newsfeed_post_data_friend_query)){
$newsfeed_post_data_friend_guyid = $newsfeed_post_data_friend['guy_id']; // <-- This is the number I need to get to fit in the loop.
$newsfeed_post_data_query = @mysqli_query($db,"SELECT * FROM giccos_status WHERE user_id='$user_logged_userid' OR (user_id='$newsfeed_post_data_friend_guyid' AND (privacy='friend' OR privacy='friendoffriend' OR privacy='public')) ORDER BY status_id DESC LIMIT 10");
while($newsfeed_post_data = mysqli_fetch_array($newsfeed_post_data_query)){
// Get content of $newsfeed_post_data.
}
}