是啊,我是刚学的php,
还请高手指教

解决方案 »

  1.   

    一个小函数,应该能看懂吧:
    /**
     * 选择新闻列表
     *
     * @param int $from
     * @param int $to
     * @return array
     */
    function get_all_news($from, $to, $condition = '')
    {
    $sql = 'select id, title, url, updatetime, (select count(id) from matter_news ' . $condition . ') as t from matter_news ' . $condition . ' order by id desc limit ' . $from . ', ' . $to;
    $result = mysql_query($sql);
    $i = 0; 
    while ($row = mysql_fetch_array($result)) 
    {
    $r[$i]['id'] = $row['id'];
    $r[$i]['title'] = $row['title'];
    $r[$i]['url'] = $row['url'];
    $r[$i]['time'] = $row['updatetime'];
    $r[$i]['total'] = $row['t'];
    $i++;
    }
    return $r;
    }
      

  2.   

    你要实现什么功能?是这样?if(($n = mysql_num_rows($result)) == 0)
    {
        // 没选到数据要做的操作
    }
    else
    {
       // 选到数据要做的操作
    }建议LZ看看手册~