我正在编写一些必须使用年份作为暴露值的脚本。此信息保存在数据库中,我必须将其取出,但这不是问题。我必须创建将年份作为主要值公开的列表。我正在编写代码,但总是出错。
控制器:
$data['dbdata'] = $this->DBdata->serve_val('pc_year');
foreach ($data['dbdata']->result() as $data)
{
$data['sheet'] = $this->DBdata->serve_val('pc');
foreach ($data['sheet']->result() as $sht)
{
$data['vdata'][$data->idyr][$sht->idpc]['name'] = $sht->name;
$data['vdata'][$data->idyr][$sht->idpc]['properties'] = $sht->properties;
}
}
看法:
foreach ($dbdata->result() as $data)
{
echo $data->year."<br>";
foreach ($sheet->result() as $sht)
{
echo $vdata[$data->idyr][$sht->idpc]['name']."<br>";
echo $vdata[$data->idyr][$sht->idpc]['properties']."<br>";
echo "<br>";
}
}
错误:
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 1
如何正确执行此操作?