这里有段代码需要用sp写,帮忙看看?

#1 小双

 $query="select counts from tb_count10 where data2='$select' order by data1 ";
$result=mysql_query($query);
while($myrow=mysql_fetch_array($result)){
$results[]=current($myrow);
$lmbs=implode(",",$results);
}


输出$lmbs数组(上面输出的方式为:$lmbs=array(5,2));

这是我写的,要怎么改?我访问的时候,页面卡住了,超时;
 $gbCount=spClass("lib_count");
  $query="select counts from zc_count where data2='$select' order by data1 ";
  $myrow=$gbCount->findSql($query);
  //$lmbs=array(5,2);
  while($myrow){
   $results[]=current($myrow);
   $lmbs=implode(",",$results);
  }
  dump($lmbs);
  $this->lmbs=$lmbs;

2010-08-09 14:36:21

#2 jake的马甲

不是很清楚你想什么样的结果,不过可以这样改一下看看
$gbCount=spClass("lib_count");
  $query="select counts from zc_count where data2='$select' order by data1 ";
  $myrow=$gbCount->findSql($query);
foreach( $myrow as $k => $v ){
echo $k."个是".$v.'
';
}
整个数据库返回值都在,你要什么就拿吧

2010-08-09 14:50:27

#3 小双

        $query="select counts from tb_count10 where data2='$select' order by data1 ";
        $result=mysql_query($query);
        while($myrow=mysql_fetch_array($result)){
                $results[]=current($myrow);
                $lmbs=implode(",",$results);       
        }
页面里输出的内容是:10,45,10,45,10,45,3

而上面dump($myrow)输出的是二维数组:
Array
(
    [0] => Array
        (
            [counts] => 5
        )

    [1] => Array
        (
            [counts] => 2
        )

)

2010-08-09 15:00:08

#4 小双

我只要得到 "5,2"这样的数据形式,就获得值就可以了,不要数组里面还有个
Array
(
[counts] => 2
)


111.jpg111.jpg
这是数据库,我说的可能不是很清楚!

2010-08-09 15:02:01

#5 小双

搞定!我这样写的!

$gbCount=spClass("lib_count");
                $query="select counts from zc_count where data2='$select' order by data1 ";
                $myrow=$gbCount->findSql($query);
                $arrayinfo=array();
                for($i=0;$i                        array_push($arrayinfo,$myrow["$i"]['counts']);
                        $lmbs=implode(",",$arrayinfo);
                }
                dump($lmbs);

2010-08-09 15:13:42

#6 azwl

搞定!我这样写的!
小双 发表于 2010-8-9 15:13
$lmbs=implode(",",$arrayinfo) ; 放在for循环中的是什么意思?这条语句后面(在for结束前)还有语句吗?

2010-08-09 15:36:16

#7 小双

implode() 函数把数组元素组合为一个字符串。

2010-08-09 16:47:29