【发布时间】:2016-02-09 05:19:41
【问题描述】:
我有 5 条数据。
我将所有 5 条数据放入一个 while 循环内的变量中。然后,我尝试在 while 循环之外使用变量 - 但所有放入的数据仍然回显。
目前,我可以放入数据,并成功取出1条数据。我想回显所有 5 条数据。
代码:
$s = <a search query that gets data from external db>
while($data = $r->FetchRow($s)) {
$addr = 'test address';
if($data['image'] == '') { $data['image'] = 'nophoto.jpg';}
$a = '<div style="height: 85px; width: 100%;"><img src="http://website.com/'.$data['image'].'" align="left" border="0" hspace="15" alt="Click for details" height="85px" width="120px" />'.$addr.'';
}
$m = "This is a test message <br />" .
$m = "".$a."" .
$m = "This is the end of a test message";
echo $m;
【问题讨论】:
标签: php loops variables while-loop scope