Code Start End Course Location
25 per page
Go to page:
features
if ($ds= $this->db->query($query)) {
// if the query was successful, build our table array from the rows
while ($row= $this->db->getRow($ds)) {
$industries[]= array(
'Code'=> stripslashes($row['Code']),
'Start'=> stripslashes($row['Start']),
'Start'=> stripslashes($row['Start']),
'End'=> stripslashes($row['End']),
'Course'=> stripslashes($row['Course']),
'Location'=> stripslashes($row['Location']),
);
}
}
// make sure our query of industries has returned rows
if (is_array($industries)) {
// create the table header definition with each header providing a link to sort by that field
$industryTableHeader= array(
'Code'=> $objTable->prepareOrderByLink('Code', 'Code'),
'Start'=> $objTable->prepareOrderByLink('Start', 'Start'),
'End'=> $objTable->prepareOrderByLink('End', 'End'),
'Course'=> $objTable->prepareOrderByLink('Course', 'Course'),
'Location'=> $objTable->prepareOrderByLink('Location', 'Location'),
);
/**
* Example snippet using the MakeTable class.
*/
// Check if the class already exists (for multiple usage per page)
if (!class_exists('MakeTable')) {
// load the MakeTable class
include $modx->config['base_path'] . "assets/snippets/maketable/maketable.class.php";
}
// Check for number of records per page preferences and define global setting
// TODO: need to change this so you can use pagination with multiple instances per page
// Currently, you can only use pagination and sorting with one instance per page
// but you can present multiple instances without these options
if (is_numeric($_GET['pageSize'])) {
setcookie("pageSize", $_GET['pageSize'], time() + 3600000);
$maxPageSize= $_GET['pageSize'];
} else {
if (is_numeric($_COOKIE['pageSize'])) {
$maxPageSize= $_COOKIE['pageSize'];
} else {
$maxPageSize= 25;
}
}
define('MAX_DISPLAY_RECORDS_NUM', $maxPageSize);
// Instantiate a new instance of the MakeTable class
$objTable= new MakeTable();
$industries= false;
// query the total number of possible records for the table
$query= "SELECT COUNT(id) FROM modx_courses";
$numRecords= $this->db->getValue($query);
// execute the main table query with MakeTable sorting and paging features
if ($ds= $this->db->query($query)) {
// if the query was successful, build our table array from the rows
while ($row= $this->db->getRow($ds)) {
$industries[]= array(
'Code'=> stripslashes($row['Code']),
'Start'=> stripslashes($row['Start']),
'Start'=> stripslashes($row['Start']),
'End'=> stripslashes($row['End']),
'Course'=> stripslashes($row['Course']),
'Location'=> stripslashes($row['Location']),
);
}
}
// make sure our query of industries has returned rows
if (is_array($industries)) {
// create the table header definition with each header providing a link to sort by that field
$industryTableHeader= array(
'Code'=> $objTable->prepareOrderByLink('Code', 'Code'),
'Start'=> $objTable->prepareOrderByLink('Start', 'Start'),
'End'=> $objTable->prepareOrderByLink('End', 'End'),
'Course'=> $objTable->prepareOrderByLink('Course', 'Course'),
'Location'=> $objTable->prepareOrderByLink('Location', 'Location'),
);
// set the field to be appended as a query string parameter to cell/link actions
$objTable->setActionFieldName('id');
// set table styling options
$objTable->setTableClass('industryTable');
$objTable->setRowHeaderClass('headerRow');
$objTable->setRowRegularClass('regRow');
$objTable->setRowAlternateClass('altRow');
// generate the paging navigation controls
$objTable->createPagingNavigation($numRecords);
// generate the table output and assign to a variable
$industryTable = $objTable->create($industries, $industryTableHeader);
} else {
// send a message that no results were found
$industryTable = '<p>No industry records were found.</p>';
}
// output the table content to a placeholder
// NOTE: you could just as easily return $industryTable if you prefer
$modx->setPlaceholder('industryTable', $industryTable);
Code Start End Course Location 25 per page Go to page: