错误:为 foreach() 提供的参数无效
我想要获取数据库表的一行 forch 来回显每个 a 但有以下错误:
$query = $this -> db -> query('
SELECT
@rownum := @rownum + 1 rownum,
tour_foreign.id,
tour_foreign.name,
MIN(tour_foreign_residence.name_re) AS name_re,
tour_foreign.service,
tour_foreign.date_go,
tour_foreign.date_back,
tour_foreign.term,
tour_foreign.useradmin_submit,
tour_foreign.date_submit,
GROUP_CONCAT( tour_foreign_residence.name_re
ORDER BY tour_foreign_residence.name_re
SEPARATOR " "
) AS name_re_all
FROM tour_foreign
INNER JOIN tour_foreign_residence
ON ( tour_foreign.id = tour_foreign_residence.relation )
JOIN (SELECT @rownum := 0) r
WHERE tour_foreign.name LIKE "%' . $find . '%"
OR tour_foreign_residence.name_re LIKE "%' . $find . '%"
GROUP BY tour_foreign.id ');
foreach ($query->result() as $row) {
echo $row->name_re_all //thisoutput is: 11111 22222 33333 44444 ...
foreach ($row->name_re_all as $val) {
echo $val . '<br>';
}
}
遇到 PHP 错误
严重性:警告
消息:为 foreach() 提供的参数无效
文件名:core/Loader.php(679):eval() 代码
行号:86
I want for a row that get of database table forch it for echo each a but have following error:
$query = $this -> db -> query('
SELECT
@rownum := @rownum + 1 rownum,
tour_foreign.id,
tour_foreign.name,
MIN(tour_foreign_residence.name_re) AS name_re,
tour_foreign.service,
tour_foreign.date_go,
tour_foreign.date_back,
tour_foreign.term,
tour_foreign.useradmin_submit,
tour_foreign.date_submit,
GROUP_CONCAT( tour_foreign_residence.name_re
ORDER BY tour_foreign_residence.name_re
SEPARATOR " "
) AS name_re_all
FROM tour_foreign
INNER JOIN tour_foreign_residence
ON ( tour_foreign.id = tour_foreign_residence.relation )
JOIN (SELECT @rownum := 0) r
WHERE tour_foreign.name LIKE "%' . $find . '%"
OR tour_foreign_residence.name_re LIKE "%' . $find . '%"
GROUP BY tour_foreign.id ');
foreach ($query->result() as $row) {
echo $row->name_re_all //thisoutput is: 11111 22222 33333 44444 ...
foreach ($row->name_re_all as $val) {
echo $val . '<br>';
}
}
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: core/Loader.php(679) : eval()'d code
Line Number: 86
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Foreach 用于遍历数组,您将字符串作为参数传递
Foreach is used to iterate trough an array, you're passing a string as a parameter