Home >Backend Development >PHP Tutorial >php while解决思路

php while解决思路

WBOY
WBOYOriginal
2016-06-13 10:10:40945browse

php while
$query="SELECT products_id 
  FROM products
WHERE products_imgaes =146.jpg";
while($row=mysql_fetch_array($rs)){
$all_array = $row['products_id'];
echo 'one=' .$all_array."
";


  echo 'two=' .$all_array."
";
?>

假如one= 输出的结果是123,23,4545,465465,856.
可是two= 输出的结果却是856.我想要的结果是123,23,4545,465465,856.怎么办呢,帮帮忙,谢谢了。

------解决方案--------------------
把echo 'two=' .$all_array."
";写到while循环里面去。
------解决方案--------------------
可以定義個變量撒。。

PHP code
<?php $rs="SELECT products_id     FROM productsWHERE products_imgaes =146.jpg";$two = '';while($row=mysql_fetch_array($rs)){$all_array = $row['products_id'];echo 'one=' .$all_array."<br>";$two .= $all_array."<br>";}   echo 'two=' .$two;<div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn