uchome调用推荐会员blog列表

2012-11-15 16:38 来源:www.chinab4c.com 作者:uchome专家

    uchome调用推荐会员blog列表,这个主要是用来显示推荐会员的会员blog列表的。我们可以通过取得blog的会员名,来取得他们对应的blog,从而形成了blog首页。 首先我们从uchome的space表里面取得会员id,然后通过uid去uchome数据库取得blog表中的数据。以下是参考代码。

   $page = empty($_GET['page'])?1:intval($_GET['page']);
    if($page<1) $page=1;
    $order = isset($_GET['order']) ? trim($_GET['order']) : 'dateline';
    $sort = isset($_GET['sort']) ? trim($_GET['sort']) : 'desc';
    //分页
    $perpage = 12;
    $perpage = mob_perpage($perpage);
   
    $start = ($page-1)*$perpage;

    //检查开始数
    ckstart($start, $perpage);
   
    $user_arr = explode(',', $_SCONFIG['spacebarusername']);
   
    //专家个数
    $count    = empty($user_arr)? 0 :count($user_arr);
    $where    = " where username IN (".simplode(explode(',', $_SCONFIG['spacebarusername'])).")";
    $sql      = " select u.uid ,u.username,si.title from ".tname('space')." u left join ".tname('spaceinfo')." si on u.uid = si.uid and si.subtype = 'intro'  $where order by $order $sort limit $start,$perpage";
   
    $res      = $_SGLOBAL['db']->query($sql);
    $list      = array();
    while($row = $_SGLOBAL['db']->fetch_array($res)){
       
        realname_set($row['uid'], $row['username']);
       
        //获取最新日志
        $new_blog = array();
        $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('blog')." WHERE uid='".$row['uid']."' ORDER BY dateline DESC LIMIT 0,6");
        while ($value1 = $_SGLOBAL['db']->fetch_array($query)) {
            $new_blog[] = $value1;
        }
       
        $row['blog_list'] = $new_blog;
        $list[] = $row;
    }
   
    $theurl="blog.php?do=experts&order=$order&sort=$sort";
    $multi = multi($count, $perpage, $page, $theurl);

   来源:http://www.chinab4c.com