当前位置: 动力学知识库 > 问答 > 编程问答 >

php - How can I output all results of a while loop as a string?

问题描述:

I am wanting to pull data from MySQL and create a string with all the data pulled in a string as 1 variable.

while($row = mysqli_fetch_array($res))

{

$x= $row['SessionValue'];

}

I know that this is miles away from what I am after but if the data pulled is: a,b,c,d (commas representing each loop) my desired output would be:

$x='<li>a</li><li>b</li><li>c</li><li>d</li>'

How would I do this?

网友答案:

Just chain it in a variable

while($row = mysqli_fetch_array($res))
{

     $x= $x."<li>".$row['SessionValue']."</li>";

}
分享给朋友:
您可能感兴趣的文章:
随机阅读: