编辑:根据您的代码示例:尝试$menu .= <your result>
or $menu = $menu . <your result>
而不是$menu = <your result>
。但尚不清楚您是否期待多个结果
如果你正在循环遍历 mySQL 查询的结果,你应该这样做:
$query = sprintf("SELECT firstname, lastname, address, age FROM friends WHERE firstname='%s' AND lastname='%s'",
mysql_real_escape_string($firstname),
mysql_real_escape_string($lastname));
// Perform Query
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
echo $row['firstname'];
echo $row['lastname'];
echo $row['address'];
echo $row['age'];
}
http://php.net/manual/en/function.mysql-query.php http://php.net/manual/en/function.mysql-query.php
如果您要循环访问文件的内容,您应该执行以下操作:
<?php
$file = fopen("welcome.txt", "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
while(!feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
?>
http://www.w3schools.com/php/php_file.asp http://www.w3schools.com/php/php_file.asp
php 手册 fopen https://www.php.net/manual/en/function.fopen.php
我希望这会有所帮助,但您的问题对于如何/在何处使用 EOF 不是很清楚。