您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

while 的变量传出去不一样?该如何解决

2024/4/2 19:01:37发布16次查看
while 的变量传出去不一样?
function type_son_id_finder($type_id){
$query=mysql_query(select id from `protduct_type` where `f_id` = '$type_id');
while ($row=mysql_fetch_assoc($query)) {
return $all_son = $row[id].,;
}
}

这个方法是输入一个父栏目id 就查找到有什么子栏目id
以上的方法
应该是输出
1,2,
但只能输出
1,
但如果把
                return $all_son = $row[id].,;
改为:
                echo $all_son = $row[id].,;
就能正常的显示出1,2,
这是为什么?
我如何解决?
我是想把这个方法最终输出成
1,2
让我在mysql中 where id in (1,2)
但现在只能输出第一个,还不能用return, 只能用echo?
求解!
------解决方案--------------------
function type_son_id_finder($type_id){
        $query=mysql_query(select id from `protduct_type` where `f_id` = '$type_id');
        $all_son = '';
        while ($row=mysql_fetch_assoc($query)) {
                $all_son .= $row[id].,;
        }
        return $all_son;
}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product