Home  >  Article  >  Backend Development  >  一个小疑点 在线请求解答

一个小疑点 在线请求解答

WBOY
WBOYOriginal
2016-06-13 13:50:02825browse

一个小问题 在线请求解答
$query = "select ncc from City";
$result=mysql_query($query);
while(list($ncc) = mysql_fetch_row($result)){ 
  $a=$ncc.',';
  //echo $a;
  }
$string="$a";
我希望将所有数据库的ncc数值全部传给$a 让$string="所有ncc";如何实现 谢谢了

------解决方案--------------------
$a-'';
while(list($ncc) = mysql_fetch_row($result)){ 
$a.=$ncc;
}
$string=$a;
------解决方案--------------------
$a = '';
$query = "select ncc from City";
$result=mysql_query($query);
while(list($ncc) = mysql_fetch_row($result)){ 
  $a .=$ncc.',';
//echo $a;
}
$string="$a";
------解决方案--------------------
少了个等号:
$a='';
while(list($ncc) = mysql_fetch_row($result)){ 
$a.=$ncc;
}
$string=$a;
------解决方案--------------------
while(list($ncc[]) = mysql_fetch_row($result));
array_pop($ncc);
$string = join(',', $ncc);

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