我收到了这个错误,这是我的代码我试图显示一个带有链接标题的表,但我试图使用分页,我收到了这个错误
foreach ($actor as $projects ) {
echo '<tr><td><a href="'.
base_url('show_project?id='.
$projects['proj_id']).
'">'.
$projects['title'].
'</td><td>'.
$projects['abbrev'].
'</td><td>'.
date('F d, Y (h:i A)', strtotime($projects['date_uploaded'])).
'</td><td>'.
$projects['professor'].
'</td></tr>'
;
}
答案 0 :(得分:0)
你的主要问题是你有一个对象而不是一个数组。要修复该对象,请$projects->title
。
我已经清理了代码,主要是使用"$object"
解释的字符串。
// your data should be changed to something like foreach($actor->projects as
$project) to make more sense
foreach ($actor as $project ) {
echo generateTableRow($project);
}
function generateTableRow($project)
{
$projectUrl = base_url("show_project?id=$project->project_id");
$date = date('F d, Y (h:i A)', strtotime($project->date_uploaded));
$tableRow = '<tr>';
$tableRow .= "<td><a href=\"$projectUrl\">$project->title</td>"
$tableRow .= "<td>$project->abbrev</td>";
$tableRow .= "<td>$date</td>";
$tableRow .= "<td>$project->professor</td>";
$tableRow .= '</tr>';
return $tableRow;
}