我将从SQL server数据库检索到的记录数组存储在一个对象$result中。我想访问数组对象中的每一项,并将其打印到屏幕上。我如何才能做到这一点?我的尝试如下
$result = $DB->get_records_sql("SELECT rawname, ID FROM mdl_tag where tagType = 'institution'");
$result = array();
foreach ($result as $ $value) {
echo $value;
);
}
发布于 2018-06-09 02:54:00
下面是正确的代码:
// Get results from table 'tag', where 'tagtype' matches 'institution', with no sorting and returning fields 'id' and 'rawname'.
$results = $DB->get_records('tag', ['tagtype' => 'institution'], '', 'id, rawname');
foreach ($results as $value) {
echo $value->rawname;
}
因此,有许多问题:
https://stackoverflow.com/questions/50765667
复制相似问题