我在数据库中有这些值:
|12||3||28||7||54|
我的代码(见下文)返回这些字符串:
用户名_12
用户名_3
用户名_28
如何反向排序?
如何获得这些值:
用户名_54
用户名_7
用户名_28
function display_user_friends($profileuserid,$friends,$base_url,$rewrite,$template_directory,$default_avatar) {
if(!empty($friends)){
$x = 0;
$friends = explode("|",$friends);
foreach($friends as $friend) {
if($friend>0 && (strpos($already_displayed,"|$friend|")===false) && ($x < 3) {
$sql_query = "SELECT username,userid FROM users WHERE userid = $friend && userstatus = 1 LIMIT 1";
$result = @mysql_query($sql_query);
if(mysql_num_rows($result))
{
while($row = mysql_fetch_array($result))
{
$x++;
$already_displayed.="|$friend|";
$username = stripslashes($row['username']);
$userid = $row['userid'];
$content.="<b>$username</b><br>";
}
}
}
}
}
else
$content = "No friends found.";
return $content;
}