Good day, I'm still new to PHP so bare with me,
my sql works in php myadmin, but when I try to display the table in php, the array doesn't get any of the values from the object
lines generating the error are all 5 $row[] = $record->column_name;
$sql = "Select
DATE(FROM_UNIXTIME(timecreated)) AS 'date',
COUNT(DISTINCT userid) AS 'unique_visitor',
SUM(IF (action = 'viewed', 1,0)) AS 'viewed',
SUM(IF (action = 'created', 1,0)) AS 'created',
SUM(IF (action = 'restored', 1,0)) AS 'restored'
FROM `table_name`
WHERE `courseid` = $courseId AND (`timecreated` Between $startDateU AND $endDateU)
GROUP BY DATE(FROM_UNIXTIME(timecreated))";
PHP code
$records = $DB->get_record_sql($sql, null);
//create the table
$table->define_columns(array('date', 'unique_visitor', 'viewed', 'created', 'restored'));
$table->define_headers(array('Date', 'Unique Visitor', 'Viewed', 'Created', 'Restored'));
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide table-bordered');
$table->show_download_buttons_at(array(TABLE_P_BOTTOM));
$table->setup();
print_r($records) . "<br><br>";
if ($records) {
foreach ($records as $record) {
$row = array();
$row[] = $record->date;
$row[] = $record->unique_visitor;
$row[] = $record->viewed;
$row[] = $record->created;
$row[] = $record->restored;
$table->add_data($row);
}
}
$table->finish_output();
this is the result where I see the object before the table, but cant build the array, thus the table is blank