Am getting the error in the code igniter view page as
Invalid argument supplied for foreach() codeigniter in the following co开发者_Python百科de;
<html>
<head>
<title><?=$page_title?></title>
</head>
<body>
<?php foreach($result as $row):?>
<h3><?=$row->title?></h3>
<p><?=$row->text?></p>
<br />
<?php endforeach;?>
</body>
Test the $result
if it is an array, before using foreach on it. Your result may be false
since your database query failed, or returned no result.
if (is_array($result))
{
foreach($result as $row)
{
/* ... */
}
}
$result
is not an array at all.
You should check the $result
construction code. you are not setting $result
properly.
If $result
is supposed to hold database rows, checkout the database query if that is returning result properly.
精彩评论